コード例 #1
0
ファイル: test_offline.py プロジェクト: uliana291/financeager
    def test_failed_recover(self):
        period_name = "123"
        kwargs = dict(name="money", value=111, period=period_name)
        command = "add"
        self.assertTrue(add(command, offline_filepath=self.filepath, **kwargs))
        self.assertTrue(add(command, offline_filepath=self.filepath, **kwargs))

        # Create client, and fake the run method
        client = utils.Client()

        def run(command, **kwargs):
            raise Exception

        client.run = run

        self.assertRaises(
            OfflineRecoveryError,
            recover,
            client,
            offline_filepath=self.filepath)

        content = _load(self.filepath)
        kwargs["command"] = command
        self.assertDictEqual(content[0], kwargs)
        self.assertDictEqual(content[1], kwargs)
コード例 #2
0
ファイル: test_offline.py プロジェクト: s1782662/financeager
    def test_failed_recover(self, run_mock):
        run_mock.side_effect = Exception()

        period_name = "123"
        kwargs = dict(name="money", value=111, period=period_name)
        command = "add"
        self.assertTrue(add(command, offline_filepath=self.filepath, **kwargs))
        self.assertTrue(add(command, offline_filepath=self.filepath, **kwargs))

        proxy = local_proxy()
        self.assertRaises(OfflineRecoveryError,
                          recover,
                          proxy,
                          offline_filepath=self.filepath)

        content = _load(self.filepath)
        kwargs["command"] = command
        self.assertDictEqual(content[0], kwargs)
        self.assertDictEqual(content[1], kwargs)
コード例 #3
0
ファイル: test_offline.py プロジェクト: uliana291/financeager
    def test_add_recover(self):
        period_name = "123"
        kwargs = dict(name="money", value=111, date="01-31", period=period_name)
        self.assertTrue(add("add", offline_filepath=self.filepath, **kwargs))

        content = _load(self.filepath)

        self.assertIsInstance(content, list)
        self.assertEqual(len(content), 1)
        data = content[0]
        self.assertEqual(data.pop("command"), "add")
        self.assertDictEqual(kwargs, data)

        client = utils.Client()
        self.assertTrue(recover(client, offline_filepath=self.filepath))

        element = client.proxy.run("get", eid=1, period=period_name)["element"]
        self.assertEqual(element["name"], "money")
        self.assertEqual(element["value"], 111)