def test_create_with_duplicate_attrs(self, attributes): """ Verify that, if a user has a credential with attributes then its values can be updated. """ # create credential with attributes user_credential = factories.UserCredentialFactory.create( username=self.username, credential=self.program_cert) factories.UserCredentialAttributeFactory( user_credential=user_credential, name="whitelist_reason", value="Reason for whitelisting.") self.assertTrue(user_credential.attributes.exists()) data = { "username": self.username, "credential": { "program_id": self.program_id }, "attributes": attributes } # 2nd attempt to create credential with attributes. response = self._attempt_create_user_credentials(data) self.assertEqual(response.status_code, 201) self._assert_usercredential_fields(response, self.username, attributes)
def setUp(self): super().setUp() self.program_certificate = factories.ProgramCertificateFactory(site=self.site) self.signatory_1 = factories.SignatoryFactory() self.signatory_2 = factories.SignatoryFactory() self.program_certificate.signatories.add(self.signatory_1, self.signatory_2) self.user_credential = factories.UserCredentialFactory( username=self.MOCK_USER_DATA["username"], credential=self.program_certificate ) self.visible_date_attr = factories.UserCredentialAttributeFactory( user_credential=self.user_credential, name="visible_date", value="1970-01-01T01:01:01Z", ) self.platform_name = self.site.siteconfiguration.platform_name user = UserFactory(username=self.MOCK_USER_DATA["username"]) self.client.login(username=user.username, password=USER_PASSWORD)