Exemple #1
0
 def setUp(self):
     self.fixture = fixtures.ServiceFixture()
     self.project = self.fixture.project
     self.associated_certification = factories.ServiceCertificationFactory()
     self.project.certifications.add(self.associated_certification)
     self.new_certification = factories.ServiceCertificationFactory()
     self.url = factories.ProjectFactory.get_url(
         self.project, action='update_certifications')
Exemple #2
0
    def test_certification_state_is_erred_if_project_certifications_is_not_a_subset_of_service_certifications(
            self):
        self.client.force_authenticate(self.fixture.owner)
        link = self.fixture.service_project_link
        service_certification = factories.ServiceCertificationFactory()
        project_certification = factories.ServiceCertificationFactory()
        link.service.settings.certifications.add(service_certification)
        link.project.certifications.add(project_certification)
        url = factories.ProjectFactory.get_url(link.project)

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertIsNotNone('validation_state', response.data['services'][0])
        self.assertEqual(response.data['services'][0]['validation_state'],
                         "ERRED")
Exemple #3
0
    def test_link_validation_state_is_ERRED_if_service_does_not_satisfy_project_certifications(self):
        certification = factories.ServiceCertificationFactory()
        self.assertEqual(self.link.States.OK, self.link.validation_state)

        self.link.project.certifications.add(certification)

        self.assertEqual(self.link.States.ERRED, self.link.validation_state)
Exemple #4
0
    def test_link_validation_state_is_OK_if_project_certifications_is_a_subset_of_service_certifications(self):
        certifications = factories.ServiceCertificationFactory.create_batch(2)
        self.link.project.certifications.add(*certifications)
        certifications.append(factories.ServiceCertificationFactory())

        self.link.service.settings.certifications.add(*certifications)

        self.assertEqual(self.link.States.OK, self.link.validation_state)
    def test_resource_cannot_be_created_for_invalid_service_project_link(self):
        self.service_project_link.project.certifications.add(
            factories.ServiceCertificationFactory())
        self.assertFalse(self.service_project_link.is_valid)
        payload = {
            'service_project_link':
            factories.TestServiceProjectLinkFactory.get_url(
                self.service_project_link),
            'name':
            'impossible resource',
        }
        url = factories.TestNewInstanceFactory.get_list_url()

        response = self.client.post(url, payload)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertIn('service_project_link', response.data)
Exemple #6
0
    def test_user_can_specify_certifications(self):
        self.client.force_authenticate(self.fixture.owner)
        data = self._get_valid_project_payload(self.fixture.customer)
        certificate = factories.ServiceCertificationFactory()
        data['certifications'] = [{
            "url":
            factories.ServiceCertificationFactory.get_url(certificate)
        }]

        response = self.client.post(factories.ProjectFactory.get_list_url(),
                                    data)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertTrue(
            Project.objects.filter(name=data['name'],
                                   customer=self.fixture.customer).exists())
        self.assertTrue(
            models.ServiceCertification.objects.filter(
                projects__name=data['name'], name=certificate.name).exists())