def setUp(self):
        super().setUp()

        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=1,
            description='a',
            repeats='weekly',
            ends={'how': 'never_ends'})
                                     
        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, 1)
        self.assertEqual(rt.description, 'a')
        self.assertEqual(rt.frequency, 'weekly')
        self.assertEqual(rt.ends, 'never')

        self.repeat_transaction = rt
        self.home_page = home_page
    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)
Beispiel #3
0
    def test_deletion_of_all_transactions_of_this_type(self):

        url = '{}/home?start={}&end={}'.format(self.live_server_url,
                                               '2018-01-01', '2018-01-15')
        self.driver.get(url)
        home_page = HomePage(self.driver)
        home_page.create_transaction(date=dt.date(2018, 1, 1),
                                     size=10,
                                     description='a',
                                     repeats='weekly',
                                     ends={'how': 'never_ends'})
        home_page.create_transaction(date=dt.date(2018, 1, 9),
                                     size=5,
                                     description='b')

        url = '{}/home?start={}&end={}'.format(self.live_server_url,
                                               '2018-01-01', '2018-01-15')
        self.driver.get(url)
        home_page = HomePage(self.driver)

        t_list = home_page.transaction_list
        transactions = t_list.get_transactions()

        t = transactions[1]
        t.delete()

        WebDriverWait(self.driver, 20).until(
            EC.visibility_of_element_located(
                (By.ID, 'repeat-transaction-deletion-prompt')))

        prompt = RepeatTransactionDeletionPrompt(self.driver)
        prompt.select('all_transactions_of_this_type')
        prompt.submit()

        self.driver.get(url)
        home_page = HomePage(self.driver)
        t_list = home_page.transaction_list
        transactions = t_list.get_transactions()

        self.assertEqual(len(transactions), 1)

        t = transactions[0]
        self.assertEqual(t.date, dt.date(2018, 1, 9))
        self.assertEqual(t.description, 'b')
        self.assertEqual('£5.00', t.balance)

        url = '{}/home?start={}&end={}'.format(self.live_server_url,
                                               '2018-01-01', '2018-01-22')
        self.driver.get(url)
        home_page = HomePage(self.driver)

        t_list = home_page.transaction_list
        transactions = t_list.get_transactions()

        self.assertEqual(len(transactions), 1)

        t = transactions[0]
        self.assertEqual(t.date, dt.date(2018, 1, 9))
        self.assertEqual('£5.00', t.balance)

        rts = home_page.get_repeat_transactions()
        self.assertEqual(len(rts), 0)