Пример #1
0
 def testRecordSource(self):
     dst = test_person(1)
     src0 = test_person(0)
     src1 = test_animal(0)
     
     dst.note_src_record(src0)
     dst.note_src_record(src1)
     
     self.assertIn(src0.serial, dst.get_src_record_serials())
     self.assertIn(src1.serial, dst.get_src_record_serials())
Пример #2
0
 def testSize(self):
     rs = MemoryRecordSet()
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person)
     
     person1 = test_person(1)
     person1.freeze()
     rs.add_record(person1)
     
     self.assertEqual(rs.size, person.size + person1.size)
Пример #3
0
 def testCount(self):
     rs = MemoryRecordSet()
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person)
     
     person1 = test_person(1)
     person1.freeze()
     rs.add_record(person1)
     
     self.assertEqual(rs.count, 2)
Пример #4
0
 def testGetRecord(self):
     rs = MemoryRecordSet()
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person)
     
     person1 = test_person(1)
     person1.freeze()
     rs.add_record(person1)
     
     self.assertEqual(rs.get_record(person.serial), person)
Пример #5
0
 def testHasRecord(self):
     rs = MemoryRecordSet()
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person)
     
     person2 = test_person(1)
     person2.freeze()
     rs.add_record(person2)
     
     self.assertTrue(rs.has_record(person.serial))
Пример #6
0
 def testFindMultipleRecordWithTag(self):
     rs = MemoryRecordSet()
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person, ['tagA'])
     
     person1 = test_person(1)
     person1.freeze()
     rs.add_record(person1, ['tagA'])
     
     self.assertEqual(list(sorted(rs.find_records_with_tag('tagA'))),
                      sorted([person, person1]))
Пример #7
0
 def testSize(self):
     rs = self._createRecordSet()
     
     initial = rs.size
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person)
     
     person1 = test_person(1)
     person1.freeze()
     rs.add_record(person1)
     
     self.assertEqual(rs.size - initial, person.size + person1.size)
Пример #8
0
 def testCount(self):
     rs = self._createRecordSet()
     
     initial = rs.count
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person)
     
     person1 = test_person(1)
     person1.freeze()
     rs.add_record(person1)
     
     self.assertEqual(rs.count - initial, 2)
Пример #9
0
    def testFindOneRecordWithTag(self):
        rs = MemoryRecordSet()
        
        person = test_person(0)
        person.freeze()
        rs.add_record(person, ['tagA'])
        
        self.assertEqual(list(rs.find_records_with_tag('tagA')),
                         [person, ])
        
        person1 = test_person(1)
        person1.freeze()
        rs.add_record(person1, ['tagB'])

        self.assertEqual(list(rs.find_records_with_tag('tagA')),
                         [person, ])
Пример #10
0
 def _createRecordSet(self):
     rs = EtlRecordSet(size_until_disk=50)
     for i in range(5):
         person = test_person(0)
         person.freeze()
         rs.add_record(person)
     assert(rs.on_disk)
     return rs
Пример #11
0
 def testHasRecordWithTag(self):
     rs = MemoryRecordSet()
     
     person = test_person(0)
     person.freeze()
     rs.add_record(person, ['tagA'])
     
     self.assertTrue(rs.has_record_with_tag('tagA'))
Пример #12
0
 def testConvertsToDisk(self):
     rs = EtlRecordSet(size_until_disk=50)
     self.assertFalse(rs.on_disk)
     
     for i in range(5):
         person = test_person(0)
         person.freeze()
         rs.add_record(person)
         
     self.assertTrue(rs.on_disk)
Пример #13
0
    def testRemoveRecord(self):
        rs = MemoryRecordSet()
        
        person = test_person(0)
        person.freeze()
        rs.add_record(person, ['tagA', ])
        
        person1 = test_person(1)
        person1.freeze()
        rs.add_record(person1, ['tagA', ])
        
        self.assertTrue(rs.has_record(person.serial))
        self.assertEqual(sorted(list(rs.find_records_with_tag('tagA'))),
                         sorted([person, person1]))
        
        rs.remove_record(person.serial)

        self.assertFalse(rs.has_record(person.serial))
        self.assertEqual(sorted(list(rs.find_records_with_tag('tagA'))),
                         sorted([person1]))
Пример #14
0
 def testClone(self):
     rec = test_person(0)
     cloned = rec.clone()
     self.assertEqual(rec, cloned) 
Пример #15
0
 def testAssertNotFrozen(self):
     rec = test_person(0)
     rec.assert_not_frozen()
     rec.freeze()
     with self.assertRaises(EtlRecordFrozen):
         rec.assert_not_frozen()
Пример #16
0
 def testCantUpdateFrozen(self):
     rec = test_person(1)
     rec.freeze()
     with self.assertRaises(EtlRecordFrozen):
         rec['first'] = "new"
Пример #17
0
 def testFreeze(self):
     rec = test_person(1)
     rec.freeze()
     self.assertTrue(rec.is_frozen,
                     "Record should be frozen")
Пример #18
0
 def testSetFieldValue(self):
     rec = test_person(1)
     rec['first'] = "Jane"
     rec['age'] = 20
     self.assertEquals(rec, test_person(1))
Пример #19
0
 def testGetFieldValue(self):
     rec = test_person(0)
     self.assertEquals(rec['first'], "John")
     self.assertEquals(rec['last'], "Doe")
     self.assertEquals(rec['age'], 22)
Пример #20
0
 def testCeckRecordStruct(self):
     person = test_person(0)
     self.assertIsNone(PersonTestScehma().check_record_struct(person))
Пример #21
0
 def testFieldNames(self):
     self.assertEquals(test_person(0).field_names(),
                       ['first', 'last', 'age'])
Пример #22
0
 def testIfSchemasNotEquals(self):
     self.assertNotEqual(test_person(0), test_animal(0))
Пример #23
0
 def testIfValuesNotEquals(self):
     self.assertNotEqual(test_person(0), test_person(1))
Пример #24
0
 def testEquals(self):
     self.assertEqual(test_person(0), test_person(0))
Пример #25
0
 def testSerial(self):
     self.assertIsNotNone(test_person(0).serial,
                          "Serial should not be None")
Пример #26
0
 def testAddRecord(self):
     rs = MemoryRecordSet()
     person = test_person(0)
     person.freeze()
     
     rs.add_record(person)
Пример #27
0
 def testSourceProcessor(self):
     rec = test_person(0)
     rec.set_source('processor1', 'output1')
     self.assertEqual(rec.source_processor_name, 'processor1')
     self.assertEqual(rec.source_processor_output_name, 'output1')
Пример #28
0
 def testSize(self):
     rec = test_person(0)
     self.assertLess(abs(rec.size - 20), 5) # w/in 5 of 20
Пример #29
0
 def testValues(self):
     self.assertEqual(test_person(0).values,
                      {'first': "John", 'last': "Doe", 'age': 22})
Пример #30
0
 def testFieldNamesWithoutSchema(self):
     rec = test_person(0)
     rec.set_schema(None)
     self.assertEquals(sorted(rec.field_names()),
                       sorted(['first', 'last', 'age']))