Пример #1
0
 def test_remove_fields(self):
     with open('test/testunimarc.dat', 'rb') as fh:
         record = Record(fh.read(), force_utf8=True)
     self.assertTrue(len(record.get_fields('899'))!=0)
     self.assertTrue(len(record.get_fields('702'))!=0)
     record.remove_fields('899', '702')
     self.assertTrue(len(record.get_fields('899'))==0)
     self.assertTrue(len(record.get_fields('702'))==0)
Пример #2
0
 def test_remove_fields(self):
     with open("test/testunimarc.dat", "rb") as fh:
         record = Record(fh.read(), force_utf8=True)
     self.assertTrue(len(record.get_fields("899")) != 0)
     self.assertTrue(len(record.get_fields("702")) != 0)
     record.remove_fields("899", "702")
     self.assertTrue(len(record.get_fields("899")) == 0)
     self.assertTrue(len(record.get_fields("702")) == 0)
Пример #3
0
 def test_remove_fields(self):
     with open('test/testunimarc.dat', 'rb') as fh:
         record = Record(fh.read(), force_utf8=True)
     self.assertTrue(len(record.get_fields('899'))!=0)
     self.assertTrue(len(record.get_fields('702'))!=0)
     record.remove_fields('899', '702')
     self.assertTrue(len(record.get_fields('899'))==0)
     self.assertTrue(len(record.get_fields('702'))==0)
Пример #4
0
 def test_remove_fields(self):
     with open("test/testunimarc.dat", "rb") as fh:
         record = Record(fh.read(), force_utf8=True)
     self.assertTrue(len(record.get_fields("899")) != 0)
     self.assertTrue(len(record.get_fields("702")) != 0)
     record.remove_fields("899", "702")
     self.assertTrue(len(record.get_fields("899")) == 0)
     self.assertTrue(len(record.get_fields("702")) == 0)
Пример #5
0
 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")
Пример #6
0
 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')
Пример #7
0
 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")
Пример #8
0
 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)
Пример #9
0
 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')
Пример #10
0
 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")
Пример #11
0
 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')
Пример #12
0
 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')
Пример #13
0
 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")
Пример #14
0
 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.assertEqual(len(found), 2)
Пример #15
0
 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.assertEqual(len(found), 2)
Пример #16
0
 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.assertEqual(len(found), 2)