Example #1
0
    def test_update_currency_prices(self, book_basic):
        if not is_inmemory_sqlite(book_basic) or is_not_on_web():
            print("skipping test for {}".format(book_basic))
            return

        EUR = book_basic.default_currency
        with pytest.raises(GncPriceError):
            EUR.update_prices()

        USD = book_basic.currencies(mnemonic="USD")
        USD.update_prices()

        assert len(list(USD.prices)) < 7
        assert (USD.prices.first() is None) or (USD.prices.first().commodity is USD)

        CAD = book_basic.currencies(mnemonic="CAD")
        CAD.update_prices()
        assert len(list(CAD.prices)) < 7
        assert (CAD.prices.first() is None) or (CAD.prices.first().commodity is CAD)

        # redo update prices which should not bring new prices
        l = len(list(USD.prices))
        USD.update_prices()
        assert len(list(USD.prices)) == l

        assert len(book_basic.prices) < 14
Example #2
0
    def test_update_stock_prices(self, book_basic):
        if not is_inmemory_sqlite(book_basic) or is_not_on_web():
            print("skipping test for {}".format(book_basic))
            return
        cdty = Commodity(mnemonic="AAPL", namespace="NASDAQ", fullname="Apple", book=book_basic)
        cdty["quoted_currency"] = "USD"
        assert cdty.get("quoted_currency") == "USD"
        cdty.update_prices()
        book_basic.flush()

        assert len(list(cdty.prices)) < 7
        cdty.update_prices()

        assert len(list(cdty.prices)) < 7
Example #3
0
 def test_create_stock_from_symbol(self, book_basic):
     if is_not_on_web():
         return
     factories.create_stock_from_symbol("AAPL", book_basic)
Example #4
0
 def test_create_currency_from_ISO_web(self, book_basic):
     if is_not_on_web():
         return
     assert factories.create_currency_from_ISO(
         "CAD", from_web=True).fullname == "Canadian Dollar"
Example #5
0
 def test_create_stock_from_symbol(self, book_basic):
     if is_not_on_web():
         return
     factories.create_stock_from_symbol("AAPL", book_basic)
Example #6
0
 def test_create_currency_from_ISO_web(self, book_basic):
     if is_not_on_web():
         return
     assert factories.create_currency_from_ISO("CAD", from_web=True).fullname == "Canadian Dollar"