def test_create_delete_us_east_1(self): m = DynamoDbMutex(name=random_name(), holder=random_name(), region_name='us-east-1') assert (m.lock()) m.release() DynamoDbMutex.delete_table(region_name='us-east-1')
def test_ttl(self): os.environ['DD_MUTEX_TABLE_NAME'] = random_name() name = random_name() caller = "myself" m1 = DynamoDbMutex(name=name, holder=caller, timeoutms=2 * 1000, ttl_minutes=2) m1.lock() item = m1.get_raw_lock() diff = item['Item']['ttl'] - item['Item']['expire_ts'] // 1000 print(diff) self.assertTrue(diff > 0 and diff <= 2 * 60) DynamoDbMutex.delete_table() del os.environ['DD_MUTEX_TABLE_NAME']