示例#1
0
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))
示例#2
0
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)
示例#3
0
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'])
示例#4
0
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)
示例#5
0
    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)
示例#6
0
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'))
示例#7
0
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
示例#8
0
    def tearDownClass(self):
        ark_obj = Ark(guid=self.identifier)
        delete_response = ark_obj.delete_api()

        assert delete_response.status_code == 200