def test_json_conversion_datacite(identifier, anvl, json_ld): ark = Ark(guid=identifier) ark.anvl = ingestAnvl(anvl) json, profile = ark.to_json_ld() for key in schema_keys: assert_equal(json.get(key), json_ld.get(key))
def test_json_conversion_dublin_core(identifier, anvl, json_ld): ark = Ark(guid=identifier) ark.anvl = ingestAnvl(anvl) json, profile = ark.to_json_ld() for key in dc_keys: assert_equal(json.get(key), json_ld.get(key)) assert_dict_equal(json, json_ld)
def test_ark_dev(identifier): ark = Ark(guid=identifier) assert_is_not_none(ark) ark.fetch() json_ld, profile = ark.to_json_ld() assert_is_not_none(json_ld) assert_is_instance(json_ld, dict) assert_true(profile in [None, 'erc', 'NIHdc', 'dc', 'datacite'])
def test_erc_conversion(identifier, anvl, json_ld): ark = Ark(guid=identifier) ark.anvl = ingestAnvl(anvl) json_response, profile = ark.to_json_ld() for key in keys: assert_equal(json_response.get(key), json_ld.get(key)) for key in dict_keys: assert_dict_equal(json_response.get(key), json_ld.get(key)) assert_dict_equal(json_response, json_ld)
def setUpClass(self): # validate payload try: validate(instance=self.data, schema=ark_schema) except ValidationError as err: print(err) self.assertTrue(False) test_user = UserNode.nodes.get_or_none(email='*****@*****.**') if test_user is None: self.assertTrue(False) self.ark_obj = Ark(data=self.data) self.response = self.ark_obj.post_api(test_user)
def test_ark_get(identifier): ''' Get the Metadata Back from EZID ''' ark = Ark(guid=identifier) assert_is_not_none(ark) try: ark.fetch() assert_is_not_none(ark.anvl) #print('\n') #print(ark.anvl) except Identifier404 as err: json_response = err.json_response() response_data = err.response_message assert_is_not_none(json_response) assert_is_instance(json_reponse, Response) assert_equal(json_response.status, 404) assert_is_not_none(response_data) assert_is_instance(response_data, dict) assert_true(identifier in response_data.get('@id'))
class ArkCrud(): @classmethod def setUpClass(self): # validate payload try: validate(instance=self.data, schema=ark_schema) except ValidationError as err: print(err) self.assertTrue(False) test_user = UserNode.nodes.get_or_none(email='*****@*****.**') if test_user is None: self.assertTrue(False) self.ark_obj = Ark(data=self.data) self.response = self.ark_obj.post_api(test_user) def test_put(self): response = self.response status_code = self.response.status_code response_message = json.loads( self.response.response[0].decode('utf-8')) # type checking self.assertTrue(isinstance(response, Response)) self.assertTrue(isinstance(response_message, dict)) self.assertTrue(isinstance(status_code, int)) # check if post was successfull self.assertTrue(response.status_code == 200 or self.response.status_code == 201) self.identifier = response_message.get('@id') def test_neomodel(self): pass def test_fetch(self): pass @classmethod def tearDownClass(self): ark_obj = Ark(guid=self.identifier) delete_response = ark_obj.delete_api() assert delete_response.status_code == 200
def tearDownClass(self): ark_obj = Ark(guid=self.identifier) delete_response = ark_obj.delete_api() assert delete_response.status_code == 200