This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from .get_score import get_score | |
class GetScoreTestCase(unittest.TestCase): | |
def test_offset_1(self): | |
game_stamps = [{"offset": 1, "score": {"home": 0, "away": 0}}, {"offset": 2, "score": {"home": 0, "away": 1}}] | |
self.assertEqual(get_score(game_stamps, 1), (0, 0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bisect import bisect_left | |
def get_score(game_stamps, offset): | |
''' | |
Takes list of game's stamps and time offset for which returns the scores for the home and away teams. | |
Please pay attention to that for some offsets the game_stamps list may not contain scores. | |
''' | |
if type(offset)!= int: | |
raise ValueError | |
elif offset <= game_stamps[0]['offset']: |