Skip to content

Commit

Permalink
update test names, use list compr
Browse files Browse the repository at this point in the history
  • Loading branch information
fritjof-b committed Jun 13, 2023
1 parent fc95a4d commit 8ea769f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
1 change: 0 additions & 1 deletion swedish_market_insights/inside_trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def _get_trades_by_date_query(


class InsideTradesAPI:

@staticmethod
def get_trades_by_publish_date(
from_date: date = date.today(), to_date: date = date.today()
Expand Down
5 changes: 1 addition & 4 deletions swedish_market_insights/soup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ def get_trade_entries_from_page(page_content: bytes) -> pd.DataFrame:

header_row = rows.pop(0)
columns = [col.get_text(strip=True) for col in header_row.find_all("th")]

data = []
for row in rows:
data.append([col.get_text(strip=True) for col in row.find_all("td")])
data = [[col.get_text(strip=True) for col in row.find_all("td")] for row in rows]

df = pd.DataFrame(data, columns=columns)
return df
Expand Down
16 changes: 6 additions & 10 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,32 @@
from context import utils


def test_date_from_string_pass():
def test_date_from_string_valid_input():
d = "1992-12-13"
assert utils.date_from_string(d) == date(1992, 12, 13)


def test_date_from_bad_string_fail():
def test_date_from_string_invalid_input():
d = "1992-12-13-"
try:
utils.date_from_string(d)
assert False
assert False, "Should raise ValueError"
except ValueError:
assert True


def test_volume_from_string_pass():
def test_volume_from_string_valid_input():
assert utils.parse_volume_from_string("1 000") == 1000
assert utils.parse_volume_from_string("1000") == 1000
assert utils.parse_volume_from_string("100 000") == 100000
assert utils.parse_volume_from_string("100,000,000") == 100000000


def test_volume_from_string_fail():
assert utils.parse_volume_from_string("2 000") != 1000


def test_price_from_string_pass():
def test_price_from_string_valid_input():
assert utils.parse_price_from_string("13,37") == 13.37
assert utils.parse_price_from_string("0.93") == 0.93
assert utils.parse_price_from_string("1,84184415") == 1.84184415


def test_price_from_string_fail():
def test_price_from_string_should_not_round():
assert utils.parse_price_from_string("13.37") != 13.4

0 comments on commit 8ea769f

Please sign in to comment.