Example #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))
Example #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))
    def test(self):

        url = '{}/home?start=2018-01-01&end=2018-01-22'.format(self.live_server_url)
        self.driver.get(url)
        
        home_page = HomePage(self.driver)
        home_page.create_transaction(
            date=dt.date(2018, 1, 1),
            size=1000,
            description='a',
            repeats='weekly',
            ends={'how': 'ends_after_#_transactions', 'when': 2})
                                     
        home_page.show_repeat_transactions_view()

        repeat_transactions = home_page.get_repeat_transactions()
        self.assertEqual(len(repeat_transactions), 1)

        rt = repeat_transactions[0]
        self.assertEqual(rt.start_date, dt.date(2018, 1, 1))
        self.assertEqual(rt.size, 1000)
        self.assertEqual(rt.description, 'a')
        self.assertEqual(rt.frequency, 'weekly')
        self.assertEqual(rt.ends, dt.date(2018, 1, 8))

        # change date
        rt.ends = dt.date(2018, 1, 15)
        import time
        time.sleep(15)
        rt.save()

        home_page.reload()

        expected = [
            (dt.date(2018, 1, 1), 1000, 'a', '£1,000.00'),
            (dt.date(2018, 1, 8), 1000, 'a', '£2,000.00'),
            (dt.date(2018, 1, 15), 1000, 'a', '£3,000.00'),
        ]

        check_transactions(self, home_page, expected)