def test_deep_hash_with_gets_same_results_based_on_value(sample_object): sample_object_1 = sample_object sample_object_2 = deepcopy(sample_object) assert deep_hash(sample_object_1) == deep_hash(sample_object_2) sample_object_2['this'][2]['test'] = ("of", "hashing", "mixed objects", 42) assert deep_hash(sample_object_1) == deep_hash(sample_object_2) assert is_int(deep_hash(sample_object_2))
def test_deep_hash_with_mutated_mixed_object(sample_object): sample_object_1 = sample_object sample_object_2 = deepcopy(sample_object) assert deep_hash(sample_object_1) == deep_hash(sample_object_2) sample_object_2['this'][2]['test'] = ("of", "ha5hing", "mixed objects", 42) assert deep_hash(sample_object_1) != deep_hash(sample_object_2) assert is_int(deep_hash(sample_object_2))
def test_expiration(amazing_function): """:type amazing_function: mock.MagicMock""" from cache_requests.utils import deep_hash # SETUP args, kwargs = ('amazing_function', 1, 2, 'three', 45), dict(this="is not", a="test") key = deep_hash(*args, **kwargs) assert amazing_function.redis.dbsize() == 0 assert amazing_function(1, 2, 'three', 45, this="is not", a="test") == (4, 2) # TEST EXPIRATION SET assert 990 < amazing_function.redis.pttl(key) <= 1000
def test_can_compare_args_and_kwargs_2(): assert deep_hash(1, 2, 'three', 45, this="test") != deep_hash(1, 2, 'three', 45, this="not", a="test")
def test_deep_hash_args_similiar_values(): assert deep_hash(1, 2, 'three', '45') != deep_hash(1, 2, 'three3', '45')
def test_deep_hash_args_and_kwargs(sample_object): assert deep_hash(*sample_tuple, **sample_object) == deep_hash(*sample_tuple, **sample_object)
def test_deep_hash_with_mixed_object(sample_object): assert is_int(deep_hash(sample_object)) assert deep_hash(sample_object) == deep_hash(sample_object)
def test_deep_hash_with_tuple(): assert deep_hash(sample_tuple) == deep_hash(sample_tuple) assert is_int(deep_hash(sample_tuple))
def test_deep_hash_with_string_sample_2(): assert deep_hash(sample_string_2) == deep_hash(sample_string_2) assert is_int(deep_hash(sample_string_2))
def test_deep_hash_with_string_sample_1(): assert deep_hash(sample_string_1) == deep_hash(sample_string_1) assert is_int(deep_hash(sample_string_1))