move the pinger job config into the config file
authorSalim Fadhley <sal@stodge.org>
Sat, 29 Jun 2013 23:39:02 +0000 (00:39 +0100)
committerSalim Fadhley <sal@stodge.org>
Sat, 29 Jun 2013 23:39:02 +0000 (00:39 +0100)
jenkinsapi_tests/systests/job_configs.py
jenkinsapi_tests/systests/test_jenkins_artifacts.py

index a7a4204d73906f126de49bc57915b471037154cf..59c5c479499797b81a75a8a514d51e0be0432da6 100644 (file)
@@ -125,3 +125,35 @@ SCM_GIT_JOB = """
   <buildWrappers/>
 </project>
 """
+
+JOB_WITH_ARTIFACTS = """
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+  <actions/>
+  <description>Ping a load of stuff for about 10s</description>
+  <keepDependencies>false</keepDependencies>
+  <properties/>
+  <scm class="hudson.scm.NullSCM"/>
+  <canRoam>true</canRoam>
+  <disabled>false</disabled>
+  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+  <triggers class="vector"/>
+  <concurrentBuild>false</concurrentBuild>
+  <builders>
+    <hudson.tasks.Shell>
+      <command>ping -c 5 localhost | tee out.txt</command>
+    </hudson.tasks.Shell>
+  </builders>
+  <publishers>
+    <hudson.tasks.ArtifactArchiver>
+      <artifacts>*.txt</artifacts>
+      <latestOnly>false</latestOnly>
+    </hudson.tasks.ArtifactArchiver>
+    <hudson.tasks.Fingerprinter>
+      <targets></targets>
+      <recordBuildArtifacts>true</recordBuildArtifacts>
+    </hudson.tasks.Fingerprinter>
+  </publishers>
+  <buildWrappers/>
+</project>""".strip()
\ No newline at end of file
index e1ea8863362544696c4eb4cff4778c9d7b708391..ee69ae9ab7f67b76f0136367d938270c015f2ed3 100644 (file)
@@ -6,46 +6,16 @@ import time
 import shutil
 import tempfile
 import unittest
-from jenkinsapi_tests.test_utils.random_strings import random_string
-from jenkinsapi_tests.systests.base import BaseSystemTest
 
-PINGER_JOB_CONFIG = """
-<?xml version='1.0' encoding='UTF-8'?>
-<project>
-  <actions/>
-  <description>Ping a load of stuff for about 10s</description>
-  <keepDependencies>false</keepDependencies>
-  <properties/>
-  <scm class="hudson.scm.NullSCM"/>
-  <canRoam>true</canRoam>
-  <disabled>false</disabled>
-  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
-  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
-  <triggers class="vector"/>
-  <concurrentBuild>false</concurrentBuild>
-  <builders>
-    <hudson.tasks.Shell>
-      <command>ping -c 5 localhost | tee out.txt</command>
-    </hudson.tasks.Shell>
-  </builders>
-  <publishers>
-    <hudson.tasks.ArtifactArchiver>
-      <artifacts>*.txt</artifacts>
-      <latestOnly>false</latestOnly>
-    </hudson.tasks.ArtifactArchiver>
-    <hudson.tasks.Fingerprinter>
-      <targets></targets>
-      <recordBuildArtifacts>true</recordBuildArtifacts>
-    </hudson.tasks.Fingerprinter>
-  </publishers>
-  <buildWrappers/>
-</project>""".strip()
+from jenkinsapi_tests.systests.base import BaseSystemTest
+from jenkinsapi_tests.systests.job_configs import JOB_WITH_ARTIFACTS
+from jenkinsapi_tests.test_utils.random_strings import random_string
 
 class TestPingerJob(BaseSystemTest):
 
     def test_invoke_job(self):
         job_name = 'create_%s' % random_string()
-        job = self.jenkins.create_job(job_name, PINGER_JOB_CONFIG)
+        job = self.jenkins.create_job(job_name, JOB_WITH_ARTIFACTS)
         job.invoke(block=True)
 
         b = job.get_last_build()
@@ -61,7 +31,6 @@ class TestPingerJob(BaseSystemTest):
         tempDir = tempfile.mkdtemp()
 
         try:
-            tf = tempfile.NamedTemporaryFile(mode='wb')
             artifact.save_to_dir(tempDir)
             readBackText = open(os.path.join(tempDir, artifact.filename), 'rb').read().strip()
             self.assertTrue(readBackText.startswith('PING localhost'))
@@ -69,9 +38,5 @@ class TestPingerJob(BaseSystemTest):
         finally:
             shutil.rmtree(tempDir)
 
-
-        # TODO: Actually verify the download
-
-
 if __name__ == '__main__':
     unittest.main()