def test_mandatory_custom_fields_success(self): """It should return a 200-level status code if a mandatory custom field is included.""" # Setup the mocked responses # We need to mock the /types and /customFields URLs as well # since Certificates.types and Certificate.custom_fields are called from enroll responses.add(responses.GET, self.test_types_url, json=self.types_data, status=200) responses.add(responses.GET, self.test_customfields_url, json=self.cf_data_mandatory, status=200) responses.add(responses.POST, self.test_url, json=self.test_result, status=200) # Call the function smime = SMIME(client=self.client) resp = smime.enroll( cert_type_name=self.test_ct_name, csr=self.test_csr, term=self.test_term, org_id=self.test_org, email=self.test_email, first_name=self.test_first_name, last_name=self.test_last_name, custom_fields=self.test_cf, ) # Verify all the query information self.assertEqual(resp, self.test_result) self.assertEqual(len(responses.calls), 3) self.assertEqual(responses.calls[0].request.url, self.test_types_url) self.assertEqual(responses.calls[1].request.url, self.test_customfields_url) self.assertEqual(responses.calls[2].request.url, self.test_url)
def test_success(self): """It should return a JSON if a 200-level status code is returned with data.""" # Setup the mocked response # We need to mock the /types and /customFields URLs as well # since SMIME.types and SMIME.custom_fields are called from enroll responses.add(responses.GET, self.test_types_url, json=self.types_data, status=200) responses.add(responses.GET, self.test_customfields_url, json=self.cf_data, status=200) responses.add(responses.POST, self.test_url, body=self.test_result, status=200) # Call the function smime = SMIME(client=self.client) resp = smime.enroll( cert_type_name=self.test_ct_name, csr=self.test_csr, term=self.test_term, org_id=self.test_org, email=self.test_email, first_name=self.test_first_name, last_name=self.test_last_name, ) # Verify all the query information self.assertEqual(json.dumps(resp), self.test_result) self.assertEqual(len(responses.calls), 3) self.assertEqual(responses.calls[0].request.url, self.test_types_url) self.assertEqual(responses.calls[1].request.url, self.test_customfields_url) self.assertEqual(responses.calls[2].request.url, self.test_url)