コード例 #1
0
 def test_multiple_creators(self):
     data = [
         {
             'role': 'Primary',
             'fullName': "primary",
             'nationality': 'mars'
         },
         {
             'role': 'Secondary',
             'fullName': "secondary",
             'attribution': 'attr'
         },
         {
             'role': 'Secondary',
             'fullName': "third",
             'nationality': 'mars',
             'lifeDates': '1900-2000'
         },
     ]
     result = [
         "primary (mars)", 'attr secondary', 'third (mars, 1900-2000)'
     ]
     c = creatorField(data)
     for index, creator in enumerate(c.to_array()):
         self.assertEqual(result[index], creator)
コード例 #2
0
 def test_add_display(self):
     """ Note that these intentionally will not sort to change the order for testing. """
     data = [
         {
             "fullName": "test"
         },
         {
             "fullName": "5 person",
             "human": True,
             "alive": True,
             "startDate": "1900"
         },
         {
             "fullName": "6 corporate",
             "human": False,
             "alive": True,
             "startDate": "1900"
         },
         {
             "fullName": "7 corporate",
             "human": False,
             "alive": True,
             "startDate": "1900",
             "endDate": "present"
         },
         {
             "fullName": "8 ambiguous living",
             "human": True,
             "alive": True,
             "startDate": "1962",
             "endDate": "2020"
         },
         {
             "fullName": "9 dead",
             "human": True,
             "alive": False,
             "startDate": "1962",
             "endDate": "2020"
         },
         {
             "fullName": "10 living",
             "human": True,
             "alive": True,
             "startDate": "1962"
         },
     ]
     result = [
         "test", "5 person (b. 1900)", "6 corporate (active 1900)",
         "7 corporate (active 1900 - present)",
         "8 ambiguous living (1962 - 2020)", "9 dead (1962 - 2020)",
         "10 living (b. 1962)"
     ]
     c = creatorField(data)
     data = c.add_displays()
     for index, creator in enumerate(data):
         self.assertEqual(result[index], creator["display"])
コード例 #3
0
 def test_one_both_nationality_and_lifedates(self):
     data = [{
         'fullName': "fullname",
         'nationality': 'mars',
         'lifeDates': '1900-2000'
     }]
     result = ["fullname (mars, 1900-2000)"]
     c = creatorField(data)
     for index, creator in enumerate(c.to_array()):
         self.assertEqual(result[index], creator)
コード例 #4
0
 def test__update_lifeDate(self):
     data = [
         {
             "lifeDates": "something"
         },
         {
             "lifeDates": "something",
             "alive": False,
             "startDate": "1234",
             "endDate": "1289"
         },
         {
             "lifeDates": "something",
             "alive": False,
             "startDate": "1234"
         },
         {
             "lifeDates": "something",
             "alive": False,
             "startDate": "1962",
             "endDate": "2020"
         },
         {
             "lifeDates": "something",
             "alive": True,
             "startDate": "1962",
             "endDate": "2020"
         },
         {
             "lifeDates": "something",
             "alive": True,
             "startDate": "1962"
         },
         {
             "alive": True,
             "startDate": "1962",
             "endDate": "2020"
         },
         {
             "alive": True,
             "startDate": "1962"
         },
     ]
     result = [
         "something", "1234 - 1289", "1234 - ", "1962 - 2020",
         "1962 - 2020", "1962", "1962 - 2020", "1962"
     ]
     c = creatorField(data)
     for index, creator in enumerate(data):
         c._update_lifeDate(creator)
         self.assertEqual(result[index], creator["lifeDates"])
コード例 #5
0
 def test_sorts_primary_to_the_top(self):
     data = [
         {
             'role': 'Secondary',
             'fullName': "secondary"
         },
         {
             'role': 'Primary',
             'fullName': "primary"
         },
     ]
     result = ["primary", 'secondary']
     c = creatorField(data)
     for index, creator in enumerate(c.to_array()):
         self.assertEqual(result[index], creator)
コード例 #6
0
 def test__active_for_corporate_creator(self):
     data = [
         {},
         {
             "human": False
         },
         {
             "human": True
         },
     ]
     result = ["", "active ", ""]
     c = creatorField(data)
     for index, creator in enumerate(data):
         self.assertEqual(result[index],
                          c._active_for_corporate_creator(creator))
コード例 #7
0
 def test__b_for_person_birthdate(self):
     data = [
         {},
         {
             "human": False
         },
         {
             "human": True,
             "alive": False
         },
         {
             "human": True,
             "alive": True
         },
         {
             "human": True,
             "alive": True,
             "endDate": "2020"
         },
     ]
     result = ["", "", "", "b. ", ""]
     c = creatorField(data)
     for index, creator in enumerate(data):
         self.assertEqual(result[index], c._b_for_person_birthdate(creator))
コード例 #8
0
 def test_one_fullname(self):
     data = [{'fullName': "fullname"}]
     result = ["fullname"]
     c = creatorField(data)
     for index, creator in enumerate(c.to_array()):
         self.assertEqual(result[index], creator)
コード例 #9
0
 def test_one_attribution(self):
     data = [{'attribution': 'attr', 'fullName': "fullname"}]
     result = ["attr fullname"]
     c = creatorField(data)
     for index, creator in enumerate(c.to_array()):
         self.assertEqual(result[index], creator)
コード例 #10
0
 def test__make_display(self):
     data = [
         {
             'role': 'Primary',
             'fullName': "primary",
             'nationality': 'mars'
         },
         {
             'role': 'Secondary',
             'fullName': "secondary",
             'attribution': 'attr'
         },
         {
             'role': 'Secondary',
             'fullName': "third",
             'nationality': 'mars',
             'lifeDates': '1900-2000'
         },
         {
             "fullName": "test person"
         },
         {
             "fullName": "5 person",
             "human": True,
             "alive": True,
             "startDate": "1900"
         },
         {
             "fullName": "6 corporate",
             "human": False,
             "alive": True,
             "startDate": "1900"
         },
         {
             "fullName": "7 corporate",
             "human": False,
             "alive": True,
             "startDate": "1900",
             "endDate": "present"
         },
         {
             "fullName": "8 ambiguous living",
             "human": True,
             "alive": True,
             "startDate": "1962",
             "endDate": "2020"
         },
         {
             "fullName": "9 dead",
             "human": True,
             "alive": False,
             "startDate": "1962",
             "endDate": "2020"
         },
         {
             "fullName": "10 living",
             "human": True,
             "alive": True,
             "startDate": "1962"
         },
     ]
     result = [
         "primary (mars)", 'attr secondary', 'third (mars, 1900-2000)',
         "test person", "5 person (b. 1900)", "6 corporate (active 1900)",
         "7 corporate (active 1900 - present)",
         "8 ambiguous living (1962 - 2020)", "9 dead (1962 - 2020)",
         "10 living (b. 1962)"
     ]
     c = creatorField(data)
     for index, creator in enumerate(data):
         c._update_lifeDate(creator)
         self.assertEqual(result[index], c.make_string(creator))
コード例 #11
0
 def test_one_lifedates(self):
     data = [{'fullName': "fullname", 'lifeDates': '1900-2000'}]
     result = ["fullname (1900-2000)"]
     c = creatorField(data)
     for index, creator in enumerate(c.to_array()):
         self.assertEqual(result[index], creator)
コード例 #12
0
 def test_one_nationality(self):
     data = [{'fullName': "fullname", 'nationality': 'mars'}]
     result = ["fullname (mars)"]
     c = creatorField(data)
     for index, creator in enumerate(c.to_array()):
         self.assertEqual(result[index], creator)