Пример #1
0
    def test_move(self):
        blast = self.blast

        blast.cmd_set(self.mk_fake(key='a', value='42'))
        blast.cmd_move(self.mk_fake(key='a', dest='b'))
        blast.cmd_list(self.mk_fake(key=None))
        self.assertEqual(self.fake_stdout.getvalue(), 'b\n')
        self.set_fake_buffer()
Пример #2
0
    def test_get(self):
        blast = self.blast

        blast.cmd_set(self.mk_fake(key='a', value='42'))
        blast.cmd_get(self.mk_fake(key='a'))
        self.assertEqual(self.fake_stdout.getvalue(), '42\n')
        self.set_fake_buffer()

        blast.cmd_set(self.mk_fake(key='b.c', value='42'))
        blast.cmd_get(self.mk_fake(key='b.c'))
        self.assertEqual(self.fake_stdout.getvalue(), '42\n')
        self.set_fake_buffer()

        blast.cmd_get(self.mk_fake(key='nonexistent'))
        self.assertIn('Error', self.fake_stdout.getvalue())
Пример #3
0
    def test_list(self):
        blast = self.blast

        blast.cmd_set(self.mk_fake(key='a', value='42'))
        blast.cmd_set(self.mk_fake(key='b', value='42'))
        blast.cmd_set(self.mk_fake(key='k.a', value='42'))
        blast.cmd_set(self.mk_fake(key='k.b', value='42'))
        blast.cmd_set(self.mk_fake(key='k2.a', value='42'))
        blast.cmd_list(self.mk_fake(key=None))
        self.assertEqual(self.fake_stdout.getvalue(), 'a\nb\nk.a\nk.b\nk2.a\n')
        self.set_fake_buffer()

        blast.cmd_list(self.mk_fake(key='k'))
        self.assertEqual(self.fake_stdout.getvalue(), 'k.a\nk.b\n')
        self.set_fake_buffer()

        blast.cmd_list(self.mk_fake(key='k.a'))
        self.assertIn('no entries', self.fake_stdout.getvalue())
        self.set_fake_buffer()

        blast.cmd_list(self.mk_fake(key='a'))
        self.assertIn('no entries', self.fake_stdout.getvalue())
        self.set_fake_buffer()

        blast.cmd_delete(self.mk_fake(key='a'))
        blast.cmd_delete(self.mk_fake(key='b'))
        blast.cmd_delete(self.mk_fake(key='k.a'))
        blast.cmd_delete(self.mk_fake(key='k.b'))
        blast.cmd_delete(self.mk_fake(key='k2.a'))
        blast.cmd_list(self.mk_fake(key=None))
        self.assertIn('no entries', self.fake_stdout.getvalue())
        self.set_fake_buffer()

        blast.cmd_list(self.mk_fake(key='a'))
        self.assertIn('no entries', self.fake_stdout.getvalue())
        self.set_fake_buffer()
Пример #4
0
    def test_validation(self):
        blast = self.blast

        with self.assertRaises(SystemExit):
            blast.cmd_set(self.mk_fake(key='a.b.c', value='42'))