class MotoactvTest(TestCase): def setUp(self): self.urlopener = MagicMock() self.motoactv = Motoactv(username="******", password="******", urlopener=self.urlopener) def test_login(self): response = MagicMock() self.urlopener.open.return_value = response response.read.return_value = b'{}' self.motoactv.login() self.assertTrue(self.urlopener.open.called) self.assertTrue(response.read.called) def test_past_workouts(self): self.test_login() response = MagicMock() self.urlopener.open.return_value = response response.read.return_value = PAST_WORKOUTS_DATA self.motoactv.past_workouts(START_DATE, END_DATE) self.assertTrue(self.urlopener.open.called) self.assertTrue(response.read.called)
def setUp(self): self.urlopener = MagicMock() self.motoactv = Motoactv(username="******", password="******", urlopener=self.urlopener)