示例#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')
示例#2
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])
示例#3
0
 def tearDown(self) -> None:
     db.clear()
     db.save()