def test_store_existing_db(self): subject.init() subject.store({'id': 1233, 'data': 'otherjohn'}) self.assertTrue(os.path.exists(local_pickle_file)) subject.store({'id': 1234, 'data': 'john'}) self.assertEqual(subject.bug_db['bugs'][1234]['data'], 'john') self.assertTrue(os.path.exists(local_pickle_file))
def test_too_old_db(self): subject.init() subject.bug_db['bugs'][123] = 'JUNK' subject.bug_db['created'] = old_time subject.init() self.assertFalse(os.path.exists(local_pickle_file)) self.assertEqual({}, subject.bug_db['bugs']) self.assertNotEqual(old_time, subject.bug_db['created'])
def test_invalid_pickle(self): with open(local_pickle_file, 'w+') as f: f.write("THIS AIN'T NO STINKIN' PICKLE") subject.init()
def test_one_init(self): subject.init() self.assertTrue('bug_db' in dir(subject))