Ejemplo n.º 1
0
    def test_create_issues(self):
        # if change is registered after date of start, ticket is registered
        c = CIChangeGit()
        c.time = datetime.datetime(year=2012, month=1, day=2)
        c.changeset = 'testchangeset'
        c.save()
        chg = CIChange.objects.get(type=CI_CHANGE_TYPES.CONF_GIT.id)
        self.assertEqual(chg.content_object, c)
        self.assertEqual(chg.external_key, '#123456')
        self.assertEqual(
            chg.registration_type, CI_CHANGE_REGISTRATION_TYPES.OP.id)
        CIChange.objects.all().delete()

        # removing cichange remove cichangegit child too.
        self.assertEqual(CIChangeGit.objects.count(), 0)

        # if change is registered before date of start, and change type is GIT,
        # then ticket remains WAITING
        # forever. When date is changed, and signal is send to the model
        # ticket is going to be registrated again.
        c = CIChangeGit()
        c.time = datetime.datetime(year=2012, month=1, day=1)
        c.changeset = 'testchangeset'
        c.save()
        chg = CIChange.objects.get(type=CI_CHANGE_TYPES.CONF_GIT.id)
        self.assertEqual(chg.content_object, c)
        self.assertEqual(chg.external_key, '')
        self.assertEqual(
            chg.registration_type, CI_CHANGE_REGISTRATION_TYPES.WAITING.id)
Ejemplo n.º 2
0
 def test_dont_create_issues(self):
     # the date is ok, but tickets enabled is set to no.  Dont register ticket.
     c = CIChangeGit()
     c.time = datetime.datetime(year=2012, month=1, day=2)
     c.changeset = "testchangeset"
     c.save()
     chg = CIChange.objects.get(type=CI_CHANGE_TYPES.CONF_GIT.id)
     # yeah, ticket is not registered, because disabled in config.
     self.assertEqual(chg.content_object, c)
     self.assertEqual(chg.external_key, "")
     self.assertEqual(chg.get_registration_type_display(), "Not registered")
Ejemplo n.º 3
0
 def test_dont_create_issues(self):
     # The date is ok, but tickets enabled is set to no.
     # Don't register tickets.
     c = CIChangeGit()
     c.time = datetime.datetime(year=2012, month=1, day=2)
     c.changeset = 'testchangeset'
     c.save()
     chg = CIChange.objects.get(type=CI_CHANGE_TYPES.CONF_GIT.id)
     # yeah, ticket is waiting, but not going to register because disabled
     # in config.
     self.assertEqual(chg.content_object, c)
     self.assertEqual(chg.external_key, '')
     self.assertEqual(
         chg.registration_type, CI_CHANGE_REGISTRATION_TYPES.WAITING.id)
Ejemplo n.º 4
0
 def _prepare_data_for_git_tests(self):
     git_change_1 = CIChangeGit(
         file_paths='path 1',
         comment='...',
         author='Arnold',
         changeset='123_1',
     )
     git_change_1.save()
     self.git_change_1_id = git_change_1.id
     change = CIChange.objects.get(
         type=CI_CHANGE_TYPES.CONF_GIT,
         content_type=ContentType.objects.get_for_model(git_change_1),
         object_id=self.git_change_1_id,
     )
     change.created = datetime.datetime.now() - datetime.timedelta(days=31)
     change.save()
     self.cichange_git_id = change.id
     git_change_2 = CIChangeGit(
         file_paths='path 2',
         comment='...',
         author='Arnold',
         changeset='123_2',
     )
     git_change_2.save()
     self.git_change_2_id = git_change_2.id
     change = CIChange.objects.get(
         type=CI_CHANGE_TYPES.CONF_GIT,
         content_type=ContentType.objects.get_for_model(git_change_2),
         object_id=self.git_change_2_id,
     )
     self.not_touched_cichange_git_id = change.id
Ejemplo n.º 5
0
    def test_create_issues(self):
        # if change is registered after date of start, ticket is registered
        c = CIChangeGit()
        c.time = datetime.datetime(year=2012, month=1, day=2)
        c.changeset = "testchangeset"
        c.save()
        chg = CIChange.objects.get(type=CI_CHANGE_TYPES.CONF_GIT.id)
        self.assertEqual(chg.content_object, c)
        self.assertEqual(chg.external_key, "#123456")
        self.assertEqual(chg.get_registration_type_display(), "Change")
        CIChange.objects.all().delete()

        # removing cichange remove cichangegit child too.
        self.assertEqual(CIChangeGit.objects.count(), 0)

        # if change is registered before date of start, ticket is not registered
        c = CIChangeGit()
        c.time = datetime.datetime(year=2012, month=1, day=1)
        c.changeset = "testchangeset"
        c.save()
        chg = CIChange.objects.get(type=CI_CHANGE_TYPES.CONF_GIT.id)
        self.assertEqual(chg.content_object, c)
        self.assertEqual(chg.external_key, "")
        self.assertEqual(chg.get_registration_type_display(), "Not registered")