Esempio n. 1
0
 def test_book_transactions(self, new_book):
     ncur = new_book.currencies(mnemonic="CAD")
     new_book.flush()
     assert len(new_book.currencies) == 2
     assert not new_book.is_saved
     new_book.cancel()
     assert new_book.is_saved
     assert len(new_book.currencies) == 1
     nncur = new_book.currencies(mnemonic="USD")
     new_book.flush()
     assert not new_book.is_saved
     assert len(new_book.currencies) == 2
     new_book.save()
     assert new_book.is_saved
     assert len(new_book.currencies) == 2
     new_book.delete(nncur)
     assert not new_book.is_saved
     assert len(new_book.currencies) == 1
     new_book.save()
     assert new_book.is_saved
     assert len(new_book.currencies) == 1
     nncur = new_book.currencies(mnemonic="USD")
     new_book.flush()
     assert len(new_book.currencies) == 2
     assert not new_book.is_saved
Esempio n. 2
0
 def test_book_transactions(self, new_book):
     ncur = new_book.currencies(mnemonic="CAD")
     new_book.flush()
     assert len(new_book.currencies) == 2
     assert not new_book.is_saved
     new_book.cancel()
     assert new_book.is_saved
     assert len(new_book.currencies) == 1
     nncur = new_book.currencies(mnemonic="USD")
     new_book.flush()
     assert not new_book.is_saved
     assert len(new_book.currencies) == 2
     new_book.save()
     assert new_book.is_saved
     assert len(new_book.currencies) == 2
     new_book.delete(nncur)
     assert not new_book.is_saved
     assert len(new_book.currencies) == 1
     new_book.save()
     assert new_book.is_saved
     assert len(new_book.currencies) == 1
     nncur = new_book.currencies(mnemonic="USD")
     new_book.flush()
     assert len(new_book.currencies) == 2
     assert not new_book.is_saved
Esempio n. 3
0
    def test_create_parentless_account(self, new_book):
        EUR = new_book.commodities[0]
        racc = new_book.root_account

        # create an account without parent that is not ROOT
        acc = Account(name="test account", type="ASSET", commodity=EUR)
        new_book.add(acc)
        with pytest.raises(ValueError):
            new_book.validate()
        new_book.cancel()

        # create an account without parent that is ROOT but with wrong name
        acc = Account(name="test account", type="ROOT", commodity=EUR)
        new_book.add(acc)
        with pytest.raises(ValueError):
            new_book.validate()
        new_book.cancel()

        # create an account without parent that is ROOT with correct name
        acc = Account(name="Root Account", type="ROOT", commodity=EUR)
        new_book.add(acc)
        new_book.flush()

        assert len(new_book.accounts) == 0
        root_accs = new_book.query(Account).all()
        assert len(root_accs) == 3
Esempio n. 4
0
    def test_create_parentless_account(self, new_book):
        EUR = new_book.commodities[0]
        racc = new_book.root_account

        # create an account without parent that is not ROOT
        acc = Account(name="test account", type="ASSET", commodity=EUR)
        new_book.add(acc)
        with pytest.raises(ValueError):
            new_book.validate()
        new_book.cancel()

        # create an account without parent that is ROOT but with wrong name
        acc = Account(name="test account", type="ROOT", commodity=EUR)
        new_book.add(acc)
        with pytest.raises(ValueError):
            new_book.validate()
        new_book.cancel()

        # create an account without parent that is ROOT with correct name
        acc = Account(name="Root Account", type="ROOT", commodity=EUR)
        new_book.add(acc)
        new_book.flush()

        assert len(new_book.accounts) == 0
        root_accs = new_book.query(Account).all()
        assert len(root_accs) == 3
Esempio n. 5
0
    def test_create_save_cancel_flush(self, new_book):
        EUR = new_book.commodities[0]
        EUR.mnemonic = "foo"
        assert EUR.mnemonic == "foo"
        new_book.cancel()
        assert EUR.mnemonic == "EUR"

        EUR.mnemonic = "foo"
        assert EUR.mnemonic == "foo"
        new_book.flush()
        assert EUR.mnemonic == "foo"
        new_book.cancel()
        assert EUR.mnemonic == "EUR"

        EUR.mnemonic = "foo"
        new_book.save()
        assert EUR.mnemonic == "foo"
Esempio n. 6
0
    def test_create_save_cancel_flush(self, new_book):
        EUR = new_book.commodities[0]
        EUR.mnemonic = "foo"
        assert EUR.mnemonic == "foo"
        new_book.cancel()
        assert EUR.mnemonic == "EUR"

        EUR.mnemonic = "foo"
        assert EUR.mnemonic == "foo"
        new_book.flush()
        assert EUR.mnemonic == "foo"
        new_book.cancel()
        assert EUR.mnemonic == "EUR"

        EUR.mnemonic = "foo"
        new_book.save()
        assert EUR.mnemonic == "foo"