Ejemplo n.º 1
0
 def test_ratelimit_check_indexerror_returns_True(self):
     api = Api()
     api.__xrls__ = 50
     nsinstance = api.get_world(shard=["TEST"], auto_load=False)
     ct = time()
     nsinstance.rltime = [(ct-(x+31)) for x in range(50)]
     self.assertTrue(nsinstance.ratelimitcheck(xrls=50))
Ejemplo n.º 2
0
 def test_rate_limitingcheck_isTrue_NonIndexError(self):
     api = Api()
     api.__xrls__ = 50
     nsinstance = api.get_world(shard=["TEST"], auto_load=False)
     ct = time()
     nsinstance.rltime = [(ct-(x)) for x in range(50)]
     self.assertTrue(nsinstance.ratelimitcheck(xrls=50))
Ejemplo n.º 3
0
 def test_rate_limiting_check_Sleeps(self):
     api = Api()
     nsinstance = api.get_world(shard=["TEST"], auto_load=False)
     api.__xrls__ = 50
     ct = time()
     nsinstance.rltime = [(ct+x) for x in range(0)]
     # This is to assert that the RateLimitCatch isn't meaningless
     self.assertFalse(nsinstance.ratelimitcheck(xrls=50))
     # Tests that numattempts will raise this exception at zero
     nsinstance._load(numattempt=0, retry_after=0, sleep_for=0)
     # To assure that data was not requested, so the rate-limit will not be
     # broken
     self.assertTrue(nsinstance.has_data)
Ejemplo n.º 4
0
 def test_rate_limiting_check_RaisesCatch_use_error_rl(self):
     api = Api()
     api.__xrls__ = 50
     nsinstance = api.get_world(shard=["TEST"], auto_load=False)
     nsinstance.__use_error_rl__ = True
     ct = time()
     nsinstance.rltime = [(ct+x) for x in range(0)]
     # This is to assert that the RateLimitCatch isn't meaningless
     self.assertFalse(nsinstance.ratelimitcheck(xrls=50))
     # Tests that numattempts will raise this exception at zero
     self.assertRaises(
         nationstates.core.exceptions.RateLimitCatch, nsinstance._load, numattempt=0, retry_after=0)
     # To assure that data was not requested, so the rate-limit will not be
     # broken
     self.assertFalse(nsinstance.has_data)
Ejemplo n.º 5
0
 def test_rate_limiter_handles_error_prone_zone(self):
     api = Api("AUTOMATED TESTING BY PYNATIONSTATES")
     nsinstance = api.get_world(shard=["TEST"], auto_load=False)
     nsinstance.ratelimitcheck = ratelimitcheck
     nsinstance._load()
     self.assertTrue(nsinstance.has_data)