Esempio n. 1
0
 def test_add_ref_bad_arg(self):
     er = ExternalResources('terms')
     resource1 = er._add_resource(resource='resource0', uri='resource_uri0')
     # The contents of the message are not important. Just make sure an error is raised
     with self.assertRaises(ValueError):
         er.add_ref('uuid1',
                    key='key1',
                    resource_name='resource1',
                    resource_uri='uri1',
                    entity_id='resource_id1')
     with self.assertRaises(ValueError):
         er.add_ref('uuid1',
                    key='key1',
                    resource_name='resource1',
                    resource_uri='uri1',
                    entity_uri='uri1')
     with self.assertRaises(ValueError):
         er.add_ref('uuid1',
                    key='key1',
                    resource_name='resource1',
                    resource_uri='uri1')
     with self.assertRaises(TypeError):
         er.add_ref('uuid1')
     with self.assertRaises(ValueError):
         er.add_ref('uuid1', key='key1', resource_name='resource1')
     with self.assertRaises(ValueError):
         er.add_ref('uuid1',
                    key='key1',
                    resources_idx=resource1,
                    resource_name='resource1',
                    resource_uri='uri1')
Esempio n. 2
0
    def test_piecewise_add(self):
        er = ExternalResources('terms')

        # this is the term the user wants to use. They will need to specify this
        key = er._add_key('mouse')

        resource1 = er._add_resource(resource='resource0', uri='resource_uri0')
        # the user will have to supply this info as well. This is the information
        # needed to retrieve info about the controled term
        er._add_entity(key, resource1, '10090', 'uri')

        # The user can also pass in the container or it can be wrapped up under NWBFILE
        obj = er._add_object('object', 'species')

        # This could also be wrapped up under NWBFile
        er._add_object_key(obj, key)

        self.assertEqual(er.keys.data, [('mouse', )])
        self.assertEqual(er.entities.data, [(0, 0, '10090', 'uri')])
        self.assertEqual(er.objects.data, [('object', 'species')])