From 39f42d31a6d3eadb69402ca232928200443aece0 Mon Sep 17 00:00:00 2001 From: Krishna Kumar K Date: Tue, 18 Jun 2024 10:38:28 -0700 Subject: [PATCH] rename assert_equals to assert_equal (#119) --- src/common/index_helpers.py | 11 ++++++----- src/retirement_401k/tests.py | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/common/index_helpers.py b/src/common/index_helpers.py index fec0aa3f..7ad7b92d 100644 --- a/src/common/index_helpers.py +++ b/src/common/index_helpers.py @@ -44,12 +44,13 @@ def update_indexes(start_date, end_date): if (today - k).days <=5 or k.day in [25, 26, 27, 28, 29, 30, 31, 1, 2, 3, 4, 5]: add_hip(index, k, v) elif abs((v-last_val)*100/(last_val+1)) > 1: - add_hip(index, k, v) + add_hip(index, k, v) last_val = v except Exception as ex: print(f'exception {ex} when updating index {index.country}/{index.name}') def update_index(exchange, start_date, end_date): + today = datetime.date.today() symbol, country = get_comp_index(exchange) if symbol: try: @@ -65,10 +66,10 @@ def update_index(exchange, start_date, end_date): yf.close() last_val = 0 for k,v in response.items(): - if k.day in [25, 26, 27, 28, 29, 30, 31, 1, 2, 3, 4, 5]: + if (today - k).days <=5 or k.day in [25, 26, 27, 28, 29, 30, 31, 1, 2, 3, 4, 5]: add_hip(index, k, v) elif abs((v-last_val)*100/(last_val+1)) > 1: - add_hip(index, k, v) + add_hip(index, k, v) last_val = v def add_hip(index, date, points): @@ -128,11 +129,11 @@ def get_comp_index_values(stock, start_date, last_date): if first_missing and first_found and (first_found - first_missing).days > 15: print(f'from get_comp_index_values: first_missing {first_missing} first_found {first_found}') - update_index_points(stock.exchange, first_missing, first_found) + update_index_points(stock.exchange, first_found, first_missing) if last_missing and last_found and (last_missing - last_found).days > 15: print(f'from get_comp_index_values: last_missing {last_missing} last_found {last_found}') - update_index_points(stock.exchange, last_missing, last_found) + update_index_points(stock.exchange, last_found, last_missing) if not first_found and not last_found: print(f'from get_comp_index_values: first_found {first_found} last_found {last_found}') diff --git a/src/retirement_401k/tests.py b/src/retirement_401k/tests.py index 8ae012d7..0a2664b3 100644 --- a/src/retirement_401k/tests.py +++ b/src/retirement_401k/tests.py @@ -87,17 +87,17 @@ def test_add_account(self): self.assertEqual(len(rows), 1) columns = rows[0].find_elements(By.TAG_NAME, 'td') anc = columns[0].find_elements(By.TAG_NAME, 'a') - self.assertEquals(anc[0].text, 'Personal') - self.assertEquals(columns[1].text, 'Oct. 4, 2010') + self.assertEqual(anc[0].text, 'Personal') + self.assertEqual(columns[1].text, 'Oct. 4, 2010') time.sleep(5) - self.assertEquals(columns[2].text, 'None') - self.assertEquals(columns[3].text, user.name) - self.assertEquals(columns[4].text, '') - self.assertEquals(columns[5].text, '0.00') - self.assertEquals(columns[6].text, '0.00') - self.assertEquals(columns[7].text, '0.00') - self.assertEquals(columns[8].text, 'None') - self.assertEquals(columns[9].text, '0.00') + self.assertEqual(columns[2].text, 'None') + self.assertEqual(columns[3].text, user.name) + self.assertEqual(columns[4].text, '') + self.assertEqual(columns[5].text, '0.00') + self.assertEqual(columns[6].text, '0.00') + self.assertEqual(columns[7].text, '0.00') + self.assertEqual(columns[8].text, 'None') + self.assertEqual(columns[9].text, '0.00') trans = columns[10].find_element(By.XPATH, "./a[contains(@href,'transactions')]") trans.click() @@ -110,4 +110,4 @@ def test_add_account(self): ''' source venv/bin/activate python manage.py test retirement_401k -''' \ No newline at end of file +'''