Ejemplo n.º 1
0
 def test_descriptive_metadata_get_dict(self):
     n = Name('Tom Elliott')
     assert_equal(n.display_name, 'Tom Elliott')
     assert_equal(n.sort_val, 'tomelliott')
     m = DescriptiveMetadata(agents=[Agent(names=[n])],
                             titles=[Title('A quick trip to Zucchabar')])
     d = m.get_dict()
     assert_dict_equal(
         d, {
             'agents': [{
                 'names': [{
                     'full_name': 'Tom Elliott',
                     'display_name': 'Tom Elliott',
                     'sort_val': 'tomelliott',
                     'name_type': 'personal',
                     'lang': 'und'
                 }],
                 'role':
                 'photographer',
                 'uris': []
             }],
             'copyright': [],
             'descriptions': [],
             'keywords': [],
             'titles': [{
                 'sort_val': 'aquicktriptozucchabar',
                 'lang': 'und',
                 'title_type': 'full',
                 'value': 'A quick trip to Zucchabar',
             }]
         })
Ejemplo n.º 2
0
 def test_descriptive_metadata_write_json(self):
     m = DescriptiveMetadata(agents=[Agent(names=[Name('Tom Elliott')])],
                             titles=[Title('A quick trip to Zucchabar')])
     path = join(test_data_path, 'zucchabar.json')
     m.write_json(path)
     with open(path, 'r', encoding='utf-8') as f:
         d = json.load(f)
     del f
     assert_dict_equal(
         d, {
             "agents": [{
                 "names": [{
                     "display_name": "Tom Elliott",
                     "full_name": "Tom Elliott",
                     "lang": "und",
                     "name_type": "personal",
                     "sort_val": "tomelliott"
                 }],
                 "role":
                 "photographer",
                 "uris": []
             }],
             "copyright": [],
             "descriptions": [],
             "keywords": [],
             "titles": [{
                 "lang": "und",
                 "sort_val": "aquicktriptozucchabar",
                 "title_type": "full",
                 "value": "A quick trip to Zucchabar"
             }]
         })
Ejemplo n.º 3
0
 def test_descriptive_metadata(self):
     """Test descriptive metadata"""
     m = DescriptiveMetadata(agents=[Agent(names=[Name('Tom Elliott')])],
                             titles=[Title('A quick trip to Zucchabar')])
     assert_equal(str(m.agents[0]), 'photographer: Tom Elliott')
     assert_equal(m.titles[0].value, 'A quick trip to Zucchabar')
     assert_equal(m.titles[0].sort_val, 'aquicktriptozucchabar')
Ejemplo n.º 4
0
 def test_agent(self):
     """Test agent creation"""
     names = [Name('Tom Elliott')]
     a = Agent(names, uris=['http://orcid.org/0000-0002-4114-6677'])
     assert_equal(a.names[0].full_name, 'Tom Elliott')
     assert_equal(a.role, RoleTerm.PHOTOGRAPHER)
     assert_equal(a.uris[0], 'http://orcid.org/0000-0002-4114-6677')
     assert_equal(str(a), 'photographer: Tom Elliott')
Ejemplo n.º 5
0
 def test_descriptive_metadata_title_bad(self):
     """Test descriptive metadata with badly formatted title"""
     m = DescriptiveMetadata(
         agents=[{
             'names': [Name('Tom Elliott')]
         }],
         titles=['the', 'road', 'goes', 'ever', 'ever', 'on'])
     del m
Ejemplo n.º 6
0
 def test_descriptive_metadata_title_dict(self):
     """Test descriptive metadata with title info in a dict"""
     m = DescriptiveMetadata(agents=[{
         'names': [Name('Tom Elliott')]
     }],
                             titles=[{
                                 'title_val':
                                 'A quick trip to Zucchabar'
                             }])
     assert_equal(str(m.agents[0]), 'photographer: Tom Elliott')
     assert_equal(m.titles[0].value, 'A quick trip to Zucchabar')
Ejemplo n.º 7
0
 def test_name(self):
     """Test name creation"""
     d = {
         'full_name': 'Tom Elliott',
         'display_name': 'Elliott, Tom',
         'name_type': NameType.PERSONAL,
         'lang': 'en'
     }
     n = Name(**d)
     assert_equal(n.full_name, 'Tom Elliott')
     assert_equal(n.display_name, 'Elliott, Tom')
     assert_equal(n.sort_val, 'elliotttom')
     assert_equal(n.name_type, NameType.PERSONAL)
     assert_equal(n.lang, 'en')
     assert_equal(str(n), 'personal name: "Tom Elliott"')
Ejemplo n.º 8
0
 def test_name_auto(self):
     """Test name automatic defaults."""
     d = {'full_name': 'Tom Elliott'}
     n = Name(**d)
     assert_equal(n.sort_val, 'tomelliott')  # yeah, it's not very smart
Ejemplo n.º 9
0
 def test_descriptive_metadata_agent_dict(self):
     """Test descriptive metadata with agent info in a dict"""
     m = DescriptiveMetadata(agents=[{'names': [Name('Tom Elliott')]}])
     assert_equal(str(m.agents[0]), 'photographer: Tom Elliott')
Ejemplo n.º 10
0
 def test_agent_bad_uri(self):
     """Test agent creation"""
     names = [Name('Tom Elliott')]
     a = Agent(names, uris=['pickles!'])
     del a