Beispiel #1
0
def test_start_of_day():
    datum = Datum()
    datum.start_of_day()
    actual = datum.value

    assert actual.hour == 0
    assert actual.minute == 0
    assert actual.second == 0
Beispiel #2
0
def test_add_days():
    datum = Datum()
    datum.today()
    datum.start_of_day()

    today = datetime.today()
    #day = today.day + 1
    tomorrow = today + relativedelta(days=1)
    tomorrow = tomorrow.replace(hour=0, minute=0, second=0, microsecond=0)
    
    actual = datum.add_days(1)
    
    assert actual == tomorrow
Beispiel #3
0
    def get_transactions(self, date_from: datetime, date_to: datetime) -> List[Transaction]:
        """ Returns account transactions """
        assert isinstance(date_from, datetime)
        assert isinstance(date_to, datetime)

        # fix up the parameters as we need datetime
        dt_from = Datum()
        dt_from.from_datetime(date_from)
        dt_from.start_of_day()
        dt_to = Datum()
        dt_to.from_datetime(date_to)
        dt_to.end_of_day()

        query = (
            self.book.session.query(Transaction)
            .join(Split)
            .filter(Split.account_guid == self.account.guid)
            .filter(Transaction.post_date >= dt_from.date, Transaction.post_date <= dt_to.date)
            .order_by(Transaction.post_date)
        )
        return query.all()
def test_latest_date(session):
    """
    Test fetching the latest price.
    The date is always today, even if the latest price is not from today!
    """
    # Preparation
    add_price_for_yesterday(session)

    # Fetch the latest price for xy
    app = PriceDbApplication(session=session)
    symbol = SecuritySymbol("VANGUARD", "BOND")

    latest_price = app.get_latest_price(symbol)

    assert latest_price

    yesterday = Datum()
    yesterday.yesterday()
    yesterday.start_of_day()
    yesterday_str = yesterday.to_iso_date_string()
    assert latest_price.datum.to_iso_date_string() == yesterday_str