Exemplo n.º 1
0
 def test_swap_position_edge_cases(self):
     """
     Step.swap_positions(s1,s2) should not be used manually, but if it is used,
     we should make sure we handle some of the edge cases.
     """
     
     # cannot swap steps with negative positions
     # (in practice, negative position is used as temp values, so this can
     # in fact happen during race conditions when move routines are not used
     # within views with @transactionnn.commit_on_success)
     b = Builder(project=self.project, name="my builder")
     b.save()
     s1 = ConfigureStep(
         builder = b,
         name = "configure the code",
         command = "./configure",
     )
     s1.save()
     s2 = ShellCommandStep(
         builder = b,
         name = "run some command",
         command = "./run",
     )
     s2.save()
     s2.position = -2
     s2.save()
     self.assertRaises(Step.SimultaneousUpdateError, Step.swap_positions, s1, s2)
     
     
     # cannot swap steps from different builders
     b2 = Builder(project=self.project, name="my builder 2")
     b2.save()
     s3 = ShellCommandStep(
         builder = b2,
         name = "run some command",
         command = "./run",
     )
     s3.save()
     self.assertRaises(ValueError, Step.swap_positions, s1, s3)
 def test_creation(self):
     """
     Since this is a sibling of ShellCommandStep, we only test what is different
     """
     step = ConfigureStep(
         builder = self.builder,
         name = "configure",
         command = "./configure",
     )
     step.save()
     self.assertTrue(step.id != None)
     self.assertEqual(unicode(step), "configure")
     self.assertEqual(step.get_config_type(), _("configure"))
     
     # 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)
Exemplo n.º 3
0
    def test_with_deleted_steps(self):
        """
        If any step is deleted, this affects step_count as well as move_up,
        move_down, and addition of new step.
        """
        b = Builder(project=self.project, name="my builder")
        b.save()
        
        s = []
        # create 3 steps, mix and match step types
        s.append(CompileStep(
            builder = b,
            name = "compile the code",
            command = "make",
        ))
        s.append(ConfigureStep(
            builder = b,
            name = "configure the code",
            command = "./configure",
        ))
        s.append(ShellCommandStep(
            builder = b,
            name = "run some command",
            command = "./run",
        ))
        for step in s:
            step.save()
            self.assertNotEqual(step.id, None)

        # check initial positions
        self._update_and_confirm_order(s, [0,1,2])
        
        # get ori order
        ids = [x.id for x in s]

        # delete first item
        d = s.pop(0)
        d.delete()
        self._update_refs(s)
        ids.pop(0)

        self.assertListEqual(ids, [x.id for x in b.step_set.all()])
        
        # move bottom one up
        s[1].move_up()
        self._update_refs(s)
        ids[0],ids[1] = ids[1],ids[0]
        self.assertListEqual(ids, [x.id for x in b.step_set.all()])
        
        # move it up again (should remain the same)
        s[1].move_up()
        self._update_refs(s)
        self.assertListEqual(ids, [x.id for x in b.step_set.all()])
        
        # move bottom one down (should remain the same)
        s[0].move_down()
        self._update_refs(s)
        self.assertListEqual(ids, [x.id for x in b.step_set.all()])
        
        # add new step
        step = ConfigureStep(
            builder = b,
            name = "configure the code2",
            command = "./configure",
        )
        step.save()
        self.assertNotEqual(step.id, None)
        s.append(step)
        self._update_refs(s)
        ids.append(step.id)
        self.assertListEqual(ids, [x.id for x in b.step_set.all()])
        
        # move new step down
        step.move_down()
        self._update_refs(s)
        self.assertListEqual(ids, [x.id for x in b.step_set.all()])
        
        # move new step up
        step.move_up()
        self._update_refs(s)
        
        ids[-1],ids[-2] = ids[-2],ids[-1]
        self.assertListEqual(ids, [x.id for x in b.step_set.all()])
        
        
Exemplo n.º 4
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({}))