Esempio n. 1
0
    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')
Esempio n. 2
0
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()
Esempio n. 3
0
    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])
Esempio n. 4
0
    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),
        )
Esempio n. 5
0
 def wrapper(*args, **kwargs):
     db.load()
     result = to_wrap(*args, **kwargs)
     db.save()
     return result
Esempio n. 6
0
 def tearDown(self) -> None:
     db.clear()
     db.save()