def test_init_with_one_record(self): r = FixedEngine([RecordA]) self.assertEquals(len(r.records), 1) self.assertIs(r.records[0], RecordA) self.assertIs(r.selector('anything'), RecordA) obj = RecordA() self.assertIs(r.find_record(obj), RecordA)
def test_init_with_two_records_using_selector_string(self): self.assertRaises(AssertionError, FixedEngine, [RecordA, RecordB]) r = FixedEngine([RecordA, RecordB], selector_slice=(0, 2)) obj_a = RecordA() obj_b = RecordB() self.assertEquals(len(r.records), 2) self.assertIs(r.records[0], RecordA) self.assertIs(r.records[1], RecordB) self.assertIs(r.selector('01Ariel'), RecordA) self.assertIs(r.selector('02Ariel'), RecordB) self.assertIs(r.find_record(obj_a), RecordA) self.assertIs(r.find_record(obj_b), RecordB)