Exemple #1
0
 def test_normalize_number_normalized(self):
     """
     Test normalizing a normalized numbeer
     """
     client = NumberManager(10, synchronous=True)
     n = '2125550100'
     result = client.normalize_number(n)
     assert result == '2125550100', ('2125550100', result)
Exemple #2
0
 def test_normalize_number(self):
     """
     Test Removal of our number formatting
     """
     client = NumberManager(10, synchronous=True)
     n = '(212) 555-0100'
     result = client.normalize_number(n)
     assert result == '2125550100', ('2125550100', result)
Exemple #3
0
 def test_expire_entries(self):
     """
     Test cache expiry
     """
     # 5 second time out
     client = NumberManager(5, synchronous=True)
     numbers = (get_lead_phone_number_to_dial() for _ in range(100))
     now = time.time()
     # Sync the cache to our test
     client.last_expiry_time = now
     # generate times from -10 seconds ago to now
     times = (now + random.randint(-10, 0) for _ in range(100))
     cache = dict(zip(numbers, times))
     client.warm_cache(cache)
     times = [now - v for v in client.calls.values()]
     assert all(t <= 5 for t in times), (times, )
     # expired = set(k for k, v in cache.items() if now - v > 5)
     live = set(
         client.normalize_number(k) for k, v in cache.items()
         if now - v <= 5)
     calls = set(client.calls.keys())
     assert live.intersection(calls) == calls, (live, calls)