Beispiel #1
0
    def test(self):

        self.driver.get(self.live_server_url)
        welcome_page = WelcomePage(self.driver)
        welcome_page.login_user('*****@*****.**', 'password')

        start=datetime.date(2018, 1, 1)
        end=datetime.date(2018, 1, 15)
        url = '{}/home?start={}&end={}'.format(self.live_server_url, start, end)
        self.driver.get(url)
        homepage = HomePage(self.driver)

        homepage.create_transaction(
            description='a',
            ends={'how': 'never_ends'},
            size=10,
            date=datetime.date(2018, 1, 1),
            steps=2,
            repeats='weekly',
        )
        
        homepage.reload()

        df_balances = homepage.get_balances()
        transactions = homepage.get_transactions()

        dates = pd.date_range(datetime.date(2018, 1, 1), datetime.date(2018, 1, 15))
        values = [10.0 for i in range(14)] + [20.0]
        df_expected = pd.DataFrame({'balance': values, 'date': dates})
        df_expected = df_expected.set_index('date')
        df_expected.index = pd.to_datetime(df_expected.index)

        self.assertTrue(df_balances.equals(df_expected), (df_balances, df_expected))
Beispiel #2
0
    def test_updates_future_transactions(self):

        self.driver.get(self.live_server_url)
        welcome_page = WelcomePage(self.driver)
        welcome_page.login_user('*****@*****.**', 'password')

        start = datetime.date(2018, 1, 1)
        end = datetime.date(2018, 1, 15)
        homepage = HomePage(self.driver, self.live_server_url, start, end)

        homepage.create_transaction(date=datetime.date(2018, 1, 7),
                                    size=1,
                                    description='a')

        homepage = homepage.reload()
        homepage.create_transaction(date=datetime.date(2018, 1, 1),
                                    size=2,
                                    description='b',
                                    repeats='weekly',
                                    ends={'how': 'never_ends'})

        balances = homepage.get_balances()
        transactions = homepage.get_transactions()

        dates = pd.date_range(datetime.date(2018, 1, 1),
                              datetime.date(2018, 1, 15))
        values = [
            2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0,
            5.0, 7.0
        ]
        balances_expected = pd.DataFrame({'date': dates, 'balance': values})
        balances_expected = balances_expected.set_index('date')

        self.assertTrue(balances.equals(balances_expected),
                        (balances, balances_expected))

        values = [(t.date, t.size, t.description, t.balance)
                  for t in transactions]
        transactions = pd.DataFrame(
            values, columns=['date', 'size', 'description', 'closing_balance'])

        transactions_expected = [
            (datetime.date(2018, 1, 1), 2.0, 'b', '£2.00'),
            (datetime.date(2018, 1, 7), 1.0, 'a', '£3.00'),
            (datetime.date(2018, 1, 8), 2.0, 'b', '£5.00'),
            (datetime.date(2018, 1, 15), 2.0, 'b', '£7.00')
        ]

        transactions_expected = pd.DataFrame(
            transactions_expected,
            columns=['date', 'size', 'description', 'closing_balance'])

        self.assertTrue(transactions.equals(transactions_expected),
                        (transactions, transactions_expected))