コード例 #1
0
 def test_set_gold(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(gp=9009)[1])
         uf = UtilityFunctions(MockConfig(), self.hs)
         assert uf.set_gold(9009) == 9009
コード例 #2
0
    def test_set_gold_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_gold(39)

            history = m.request_history
            # the put method to set HP should not be called
            assert history[0].method == 'GET'
            assert len(history) == 1
コード例 #3
0
 def test_set_mana(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(mp=100)[1])
         uf = UtilityFunctions(MockConfig(), self.hs)
         uf.set_mana(100)
         history = m.request_history
         assert history[1].method == 'PUT'
         assert history[1].text == 'stats.mp=100'
コード例 #4
0
    def test_set_gold_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_gold(39)

            history = m.request_history
            # the put method to set HP should not be called
            assert history[0].method == 'GET'
            assert len(history) == 1
コード例 #5
0
 def test_dec_mana(self):
     with requests_mock.mock() as m:
         m.get('https://habitica.com/api/v3/user',
               text=get_fake_stats(mp=50)[1])
         m.put('https://habitica.com/api/v3/user',
               text=get_fake_stats(mp=39)[1])
         uf = UtilityFunctions(MockConfig(), self.hs)
         uf.set_mana(-11, True)
         history = m.request_history
         assert history[1].method == 'PUT'
         assert history[1].text == 'stats.mp=39'
コード例 #6
0
 def test_inc_health(self):
     with requests_mock.mock() as m:
         m.get('https://habitica.com/api/v3/user',
               text=get_fake_stats(hp=1)[1])
         m.put('https://habitica.com/api/v3/user',
               text=get_fake_stats(hp=8)[1])
         uf = UtilityFunctions(MockConfig(), self.hs)
         uf.set_health(7, True)
         history = m.request_history
         assert history[1].method == 'PUT'
         assert history[1].text == 'stats.hp=8'
コード例 #7
0
 def test_set_gold(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(gp=9009)[1])
         uf = UtilityFunctions(MockConfig(), self.hs)
         uf.set_gold(9009)
         history = m.request_history
         assert history[1].method == 'PUT'
         assert history[1].text == 'stats.gp=9009'
コード例 #8
0
 def test_dec_health(self):
     with requests_mock.mock() as m:
         m.get('https://habitica.com/api/v3/user',
               text=get_fake_stats(hp=50)[1])
         m.put('https://habitica.com/api/v3/user',
               text=get_fake_stats(hp=29)[1])
         uf = UtilityFunctions(MockConfig(), self.hs)
         uf.set_health(-21, True)
         history = m.request_history
         assert history[1].method == 'PUT'
         assert history[1].text == 'stats.hp=29'
コード例 #9
0
 def test_inc_gold(self):
     with requests_mock.mock() as m:
         m.get('https://habitica.com/api/v3/user',
               text=get_fake_stats(gp=30)[1])
         m.put('https://habitica.com/api/v3/user',
               text=get_fake_stats(gp=39)[1])
         uf = UtilityFunctions(MockConfig(), self.hs)
         uf.set_gold(9, True)
         history = m.request_history
         assert history[1].method == 'PUT'
         assert history[1].text == 'stats.gp=39'