def test_complex(self): td = TagDict() td.add('tag') rl = RecordList() dt = datetime(year=2021, month=1, day=15, hour=21, minute=13) rl.append(Record(dt, note='test')) ws = WordSet() with self.assertRaises(Exception): ws.check_note('test') ws.check_note('test', update=True) self.assertEqual('0) tag', str(td)) self.assertEqual('[15.01.2021 21:13:00] <tag> test', str(rl)) ws.check_note('test') db.save() db.clear() self.assertEqual('', str(td)) self.assertEqual('', str(rl)) with self.assertRaises(Exception): ws.check_note('test') db.load() self.assertEqual('0) tag', str(td)) self.assertEqual('[15.01.2021 21:13:00] <tag> test', str(rl)) ws.check_note('test')
def CreateProfile(name, createby, SKIN=None, CAPE=None): OfflineUUID = utils.OfflinePlayerUUID(name).replace("-", "") db = profile(uuid=OfflineUUID, name=name, createby=createby, skin=SKIN, cape=CAPE) db.save()
def test_simple(self): key = 'key' value = 'value' db[key] = value self.assertEqual(value, db[key]) db.save() db.clear() with self.assertRaises(KeyError): value = db[key] db.load() self.assertEqual(value, db[key])
def test_update_record(self): self._gui_manager.add_record() self.assertEqual( '<KeyError: -1>', str(self._gui_manager._diary_manager.record_list)[22:], ) self._gui_manager._diary_manager.tag_dict.add('test tag') db.save() self._gui_manager.update_record( index=0, str_dt='30.01.2021 21:26:00', tag='test tag', is_active=True, note='test note', update=True, ) self.assertEqual( '[30.01.2021 21:26:00] <test tag: start> test note', str(self._gui_manager._diary_manager.record_list), )
def wrapper(*args, **kwargs): db.load() result = to_wrap(*args, **kwargs) db.save() return result
def tearDown(self) -> None: db.clear() db.save()