Esempio n. 1
0
    def test_ci_change_cmdbhistory_registration(self):
        request = HttpRequest()
        request.path = self.post_data_cmdb_change['ci']
        request.user = self.user
        request.META['SERVER_NAME'] = 'testserver'
        request.META['SERVER_PORT'] = 80

        cmdb_bundle = Bundle(data=self.post_data_cmdb_change, request=request)
        cmdb_resource = CIChangeCMDBHistoryResource()
        cmdb_resource.obj_create(bundle=cmdb_bundle)

        cmdb_change = None
        try:
            cmdb_change = CIChangeCMDBHistory.objects.get(
                ci_id=self.ci.id, old_value=self.cmdb_old_value,
                new_value=self.cmdb_new_value)
        except CIChangeCMDBHistory.DoesNotExist:
            pass
        self.assertNotEqual(cmdb_change, None)
        self.assertEqual(
            CIChange.objects.filter(
                object_id=cmdb_change.id,
                type=chdb.CI_CHANGE_TYPES.CI.id
            ).count(),
            1,
        )
Esempio n. 2
0
    def setUp(self):
        self.puppet_cv = "v%s" % random.randrange(0, 1000)
        puppet_bundle = Bundle(
            data={
                'configuration_version': self.puppet_cv,
                'host': 's11111.dc2',
                'kind': 'apply',
                'status': 'failed',
                'time': '2012-11-14 13:00:00'
            })
        puppet_resource = CIChangePuppetResource()
        puppet_resource.obj_create(bundle=puppet_bundle)

        self.git_changeset = "change:%s" % random.randrange(0, 1000)
        self.git_comment = "comment:%s" % random.randrange(0, 1000)
        git_bundle = Bundle(
            data={
                'author': 'Jan Kowalski',
                'changeset': self.git_changeset,
                'comment': self.git_comment,
                'file_paths': '/some/path',
            })
        git_resource = CIChangeGitResource()
        git_resource.obj_create(bundle=git_bundle)

        temp_venture = Venture.objects.create(name='TempTestVenture')
        self.ci = CI.objects.create(
            name='TempTestVentureCI',
            uid=CI.get_uid_by_content_object(temp_venture),
            type_id=4)
        self.cmdb_new_value = 'nv_%s' % random.randrange(0, 1000)
        self.cmdb_old_value = 'ov_%s' % random.randrange(0, 1000)
        cmdb_bundle = Bundle(
            data={
                'ci': '/api/v0.9/ci/%d/' % self.ci.pk,
                'comment': 'test api',
                'field_name': 'child',
                'new_value': self.cmdb_new_value,
                'old_value': self.cmdb_old_value,
                'time': '2012-11-15 12:00:00'
            })
        cmdb_resource = CIChangeCMDBHistoryResource()
        cmdb_resource.obj_create(bundle=cmdb_bundle)