def test_find(self): record = Record() subject1 = Field( tag = '650', indicators = ['', '0'], subfields = ['a', 'Programming Language']) record.add_field(subject1) subject2 = Field( tag = '650', indicators = ['', '0'], subfields = ['a', 'Object Oriented']) record.add_field(subject2) found = record.get_fields('650') self.assertEqual(found[0], subject1, 'get_fields() item 1') self.assertEqual(found[0], subject1, 'get_fields() item 2') found = record.get_fields() self.assertEqual(len(found), 2, 'get_fields() with no tag')
def test_alphatag(self): record = Record() record.add_field(Field('CAT', [' ', ' '], subfields=['a', 'foo'])) record.add_field(Field('CAT', [' ', ' '], subfields=['b', 'bar'])) fields = record.get_fields('CAT') self.assertEqual(len(fields), 2) self.assertEqual(fields[0]['a'], 'foo') self.assertEqual(fields[1]['b'], 'bar') self.assertEqual(record['CAT']['a'], 'foo')
def test_multi_find(self): record = Record() subject1 = Field( tag = '650', indicators = ['', '0'], subfields = ['a', 'Programming Language']) record.add_field(subject1) subject2 = Field( tag = '651', indicators = ['', '0'], subfields = ['a', 'Object Oriented']) record.add_field(subject2) found = record.get_fields('650', '651') self.assertEquals(len(found), 2)