def test_set_xp(self): with requests_mock.mock() as m: m.get('https://habitica.com/api/v3/user', text=get_fake_stats()[1]) m.put('https://habitica.com/api/v3/user', text=get_fake_stats(exp=1009)[1]) uf = UtilityFunctions(MockConfig(), self.hs) uf.set_xp(1009) history = m.request_history assert history[1].method == 'PUT' assert history[1].text == 'stats.exp=1009'
def test_set_xp_dry_run(self): with requests_mock.mock() as m: m.get('https://habitica.com/api/v3/user', text=get_fake_stats()[1]) uf = UtilityFunctions(MockConfig(dry_run=True), self.hs) uf.set_xp(39) history = m.request_history # the put method to set XP should not be called assert history[0].method == 'GET' assert len(history) == 1
def test_set_xp(self): with requests_mock.mock() as m: m.get('https://habitica.com/api/v3/user', text=get_fake_stats()[1]) m.put('https://habitica.com/api/v3/user', text=get_fake_stats(exp=39)[1]) uf = UtilityFunctions(MockConfig(), self.hs) assert uf.set_xp(39) == 39