Esempio n. 1
0
    def test_keys_roundtrip(self):
        er = ExternalResources('terms')
        keys = pd.DataFrame(
            data=[['key1', 'resource11', 'resource_id11', 'url11'],
                  ['key1', 'resource12', 'resource_id12', 'url12'],
                  ['key2', 'resource21', 'resource_id21', 'url21']],
            columns=['key_name', 'resource_name', 'resource_entity_id', 'resource_entity_uri']
        )
        er.add_keys(keys)
        received = er.get_keys()

        pd.testing.assert_frame_equal(received, keys)
Esempio n. 2
0
    def test_add_keys(self):
        er = ExternalResources('terms')
        keys = pd.DataFrame(
            data=[['key1', 'resource11', 'resource_id11', 'url11'],
                  ['key1', 'resource12', 'resource_id12', 'url12'],
                  ['key2', 'resource21', 'resource_id21', 'url21']],
            columns=['key_name', 'resource_name', 'resource_entity_id', 'resource_entity_uri']
        )
        ret = er.add_keys(keys)

        self.assertEqual({'key1', 'key2'}, set(ret))
        self.assertEqual(er.keys.data, [('key1',), ('key2',)])
        self.assertEqual(er.resources.data,
                         [(0, 'resource11', 'resource_id11', 'url11'),
                          (0, 'resource12', 'resource_id12', 'url12'),
                          (1, 'resource21', 'resource_id21', 'url21')])