def test_save_and_restore(self): sched1 = schedules() sched1.add(self.A) sched1.add(self.B) sched1.add(self.C) store1 = file('test_schedules_and_file.sqlite') sched1.store(store1) del sched1 del store1 store2 = file('test_schedules_and_file.sqlite') sched2 = schedules.load(store2) self.assertEqual(set([x.begins for x in sched2.tasks]), set([3, 5, 7]))
def test_usage_pattern(self): sched1 = schedules() sched1.add(self.A) sched1.add(self.B) sched1.add(self.C) sched1.add(self.D) sched1.add(self.E) store1 = file('test_system.sqlite') sched1.store(store1) del store1 store2 = file('test_system.sqlite') sched2 = schedules.load(store2) self.assertEqual(sched1, sched2) sched2.remove(self.D) sched2.remove(self.E) self.assertNotEqual(sched1, sched2) sched2.add(self.F) self.assertTrue(self.F in sched2) self.assertFalse(self.F in sched1) self.assertRaises(schedule_error, sched2.add, self.D) self.assertRaises(schedule_error, sched2.add, self.E) self.assertTrue(self.A in sched1) self.assertTrue(self.B in sched1) self.assertTrue(self.C in sched1) self.assertTrue(self.D in sched1) self.assertTrue(self.E in sched1) self.assertFalse(self.F in sched1) self.assertTrue(self.A in sched2) self.assertTrue(self.B in sched2) self.assertTrue(self.C in sched2) self.assertFalse(self.D in sched2) self.assertFalse(self.E in sched2) self.assertTrue(self.F in sched2)
def setUp(self): storage = file('file_test.sqlite') storage.store_object('tag1', 'A') storage.store_object('tag2', 'B') storage.store_object('tag1', 'C') storage.store_object('tag1', 'D') storage.store_object('tag3', 'E') storage.store_object('tag3', 'F')
def test_other_instance(self): storage = file('file_test.sqlite') self.assertEqual(set(storage.load_objects('tag1')), set(['A', 'C', 'D'])) self.assertEqual(set(storage.load_objects('tag2')), set(['B'])) self.assertEqual(set(storage.load_objects('tag3')), set(['E', 'F']))