Beispiel #1
0
 def setUp(self):
     super(TestObjPaginator, self).setUp()
     p = self.project
     
     self.builder_empty = Builder(project=p, name="empty builder")
     self.builder_empty.save()
     self.builder = Builder(project=p, name="builder")
     self.builder.save()
     b = self.builder
     
     self.stepcount = 10
     for i in xrange(self.stepcount):
         step = CompileStep(builder=b, name="step-%d"%i)
         step.save()
Beispiel #2
0
    def test_position_integrity(self):
        """
        Ensure that position cannot be duplicated
        """
        b = Builder(project=self.project, name="my builder")
        b.save()
        s = CompileStep(
            builder = b,
            name = "compile the code",
            command = "make",
        )
        s.save()
        self.assertNotEqual(s.id, None)
        self.assertEqual(s.position, 0)

        s2 = CompileStep(
            builder = b,
            name = "compile the code 2",
            command = "make",
        )
        s2.save()
        s2.position = 0
        self.assertRaises(IntegrityError, s2.save)
    def test_creation(self):
        """
        Since this is a sibling of ShellCommandStep, we only test what is different
        """
        step = CompileStep(
            builder = self.builder,
            name = "compile",
            command = "make",
            arguments = "all",
        )
        step.save()
        self.assertTrue(step.id != None)
        self.assertEqual(unicode(step), "compile")
        self.assertEqual(step.get_config_type(), _("compile"))

        # try instantiating buildbot config object
        args = step.cast().get_config_args()
        self.assert_valid_buildbot_config(step.get_config_class(), args)
        
        # Check that the resulting config string is sensible
        self.assert_config_string_executable(step)
        
        
Beispiel #4
0
 def test_name_uniqueness(self):
     """
     Ensure that a builder cannot have multiple steps with the same name or position
     """
     b = Builder(project=self.project, name="my builder")
     b.save()
     s = CompileStep(
         builder = b,
         name = "compile the code",
         command = "make",
     )
     s.save()
     self.assertNotEqual(s.id, None)
     
     # another step, same name
     s2 = CompileStep(
         builder = b,
         name = "compile the code",
         command = "make",
     )
     self.assertRaises(IntegrityError, s2.save)
     self.assertEqual(s2.id, None)
     # try a different name
     s2.name = "another name"
     s2.save()
     self.assertNotEqual(s2.id, None)
     
     # try forcing same position
     s2.position = s.position
     self.assertRaises(IntegrityError, s2.save)
  
     # should be ok to have dups with a different builder
     b2 = Builder(project=self.project, name="my builder2")
     b2.save()
     s3 = CompileStep(
         builder = b2,
         name = "compile the code",
         command = "make",
     )
     s3.save()
     self.assertNotEqual(s3.id, None)
Beispiel #5
0
 def test_mixed_steps(self):
     p = self.project
     b = Builder(project=p, name="my builder")
     b.save()
     self.assertEqual(b.is_complete, False)
     
     # add shell command step
     step_shell = ShellCommandStep(
         builder = b,
         name = "a shell command",
         command = "./some_command",
     )
     step_shell.save()
     self.assertNotEqual(step_shell.id, None)
     self.assertEqual(step_shell.position, 0)
     self.assertEqual(b.step_count, 1)
     
     # add compile step
     step_compile = CompileStep(
         builder = b,
         name = "compile the code",
         command = "make",
     )
     step_compile.save()
     self.assertNotEqual(step_compile.id, None)
     self.assertEqual(step_compile.position, 1)
     self.assertEqual(b.step_count, 2)
     
     # add configure step
     step_configure = ConfigureStep(
         builder = b,
         name = "configure the code",
         command = "./configure",
     )
     step_configure.save()
     self.assertNotEqual(step_configure.id, None)
     self.assertEqual(step_configure.position, 2)
     self.assertEqual(b.step_count, 3)
     
     # add test step
     step_test = TestStep(
         builder = b,
         name = "test the code",
         command = "make",
         arguments = "test",
     )
     step_test.save()
     self.assertNotEqual(step_test.id, None)
     self.assertEqual(step_test.position, 3)
     self.assertEqual(b.step_count, 4)
     
     
     expect = [_("shell command"), _("compile"), _("configure"), _("test")]
     for i,s in enumerate(b.step_set.all()):
         # calling method on parent class should raise exception
         self.assertRaises(NotImplementedError, s.get_config_type)
         self.assertRaises(NotImplementedError, s.get_config_class)
         self.assertRaises(NotImplementedError, s.get_config_args)
         
         # should work with r.cast()
         self.assertEqual(expect[i], s.cast().get_config_type())
         
         self.assertEqual(type(s.cast().get_config_class()), type(()))
         self.assertEqual(type(s.cast().get_config_args()), type({}))