Skip to content

Commit

Permalink
adding unittesting for operation type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanAmmirati committed Apr 14, 2020
1 parent 3b17831 commit 686f20c
Showing 1 changed file with 136 additions and 0 deletions.
136 changes: 136 additions & 0 deletions tests/unit/test_nba_boxscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,142 @@ def test_invalid_home_record_returns_default_losses(self):

assert self.boxscore.home_losses == 0

def test_away_two_point_field_goals_calc(self):
fake_none = PropertyMock(return_value=None)
fake_int = PropertyMock(return_value=5)

type(self.boxscore)._away_field_goals = fake_none
type(self.boxscore)._away_three_point_field_goals = fake_none

assert self.boxscore.away_two_point_field_goals is None

type(self.boxscore)._away_three_point_field_goals = fake_int
assert self.boxscore.away_two_point_field_goals is None

type(self.boxscore)._away_field_goals = fake_int
type(self.boxscore)._away_three_point_field_goals = fake_none

assert self.boxscore.away_two_point_field_goals is None

type(self.boxscore)._away_field_goals = fake_int
type(self.boxscore)._away_three_point_field_goals = fake_int

assert isinstance(self.boxscore.away_two_point_field_goals, int)

def test_away_two_point_field_goal_attempts_calc(self):
fake_none = PropertyMock(return_value=None)
fake_int = PropertyMock(return_value=5)

type(self.boxscore)._away_field_goal_attempts = fake_none
type(self.boxscore)._away_three_point_field_goal_attempts = fake_none

assert self.boxscore.away_two_point_field_goal_attempts is None

type(self.boxscore)._away_three_point_field_goal_attempts = fake_int
assert self.boxscore.away_two_point_field_goal_attempts is None

type(self.boxscore)._away_field_goal_attempts = fake_int
type(self.boxscore)._away_three_point_field_goal_attempts = fake_none

assert self.boxscore.away_two_point_field_goal_attempts is None

type(self.boxscore)._away_field_goal_attempts = fake_int
type(self.boxscore)._away_three_point_field_goal_attempts = fake_int

assert isinstance(
self.boxscore.away_two_point_field_goal_attempts, int)

def test_away_two_point_field_goal_percentage_calc(self):
fake_none = PropertyMock(return_value=None)
fake_int = PropertyMock(return_value=5)

type(self.boxscore).away_two_point_field_goals = fake_none
type(self.boxscore).away_two_point_field_goal_attempts = fake_none

assert self.boxscore.away_two_point_field_goal_percentage is None

type(self.boxscore).away_two_point_field_goal_attempts = fake_int
assert self.boxscore.away_two_point_field_goal_percentage is None

type(self.boxscore).away_two_point_field_goals = fake_int
type(self.boxscore).away_two_point_field_goal_attempts = fake_none

assert self.boxscore.away_two_point_field_goal_percentage is None

type(self.boxscore).away_two_point_field_goals = fake_int
type(self.boxscore).away_two_point_field_goal_attempts = fake_int

assert isinstance(
self.boxscore.away_two_point_field_goal_percentage, float)

def test_home_to_point_field_goals_calc(self):
fake_none = PropertyMock(return_value=None)
fake_int = PropertyMock(return_vzalue=5)

type(self.boxscore)._home_field_goals = fake_none
type(self.boxscore)._home_three_point_field_goals = fake_none

assert self.boxscore.home_two_point_field_goals is None

type(self.boxscore)._home_three_point_field_goals = fake_int
assert self.boxscore.home_two_point_field_goals is None

type(self.boxscore)._home_field_goals = fake_int
type(self.boxscore)._home_three_point_field_goals = fake_none

assert self.boxscore.home_two_point_field_goals is None

type(self.boxscore)._home_field_goals = fake_int
type(self.boxscore)._home_three_point_field_goals = fake_int

assert isinstance(self.boxscore.home_two_point_field_goals, int)

def test_home_two_point_field_goal_attempts_calc(self):
fake_none = PropertyMock(return_value=None)
fake_int = PropertyMock(return_value=5)

type(self.boxscore)._home_field_goal_attempts = fake_none
type(self.boxscore)._home_three_point_field_goal_attempts = fake_none

assert self.boxscore.home_two_point_field_goal_attempts is None

type(self.boxscore)._home_three_point_field_goal_attempts = fake_int
assert self.boxscore.home_two_point_field_goal_attempts is None

type(self.boxscore)._home_field_goal_attempts = fake_int
type(self.boxscore)._home_three_point_field_goal_attempts = fake_none

assert self.boxscore.home_two_point_field_goal_attempts is None

type(self.boxscore)._home_field_goal_attempts = fake_int
type(self.boxscore)._home_three_point_field_goal_attempts = fake_int

assert isinstance(
self.boxscore.home_two_point_field_goal_attempts, int)

def test_home_two_point_field_goal_percentage_calc(self):
fake_none = PropertyMock(return_value=None)
fake_int = PropertyMock(return_value=5)

type(self.boxscore).home_two_point_field_goals = fake_none
type(self.boxscore).home_two_point_field_goal_attempts = fake_none

assert self.boxscore.home_two_point_field_goal_percentage is None

type(self.boxscore).home_two_point_field_goal_attempts = fake_int
assert self.boxscore.home_two_point_field_goal_percentage is None

type(self.boxscore).home_two_point_field_goals = fake_int
type(self.boxscore).home_two_point_field_goal_attempts = fake_none

assert self.boxscore.home_two_point_field_goal_percentage is None

type(self.boxscore).home_two_point_field_goals = fake_int
type(self.boxscore).home_two_point_field_goal_attempts = fake_int

assert isinstance(
self.boxscore.home_two_point_field_goal_percentage, float)

def test_game_summary_with_no_scores_returns_none(self):
result = Boxscore(None)._parse_summary(pq(
"""<table id="line_score">
Expand Down

0 comments on commit 686f20c

Please sign in to comment.