Exemplo n.º 1
0
 def test_cache_result_used_if_already_exists(self, cache):
     # mock an existing entry
     key = cache.generate_key(Country, only_id=True, code='NZ')
     cache._XRefResolver__cache[key] = 'oops!'
     id = cache.resolve(Country, only_id=True, code='NZ')
     assert id == 'oops!'
Exemplo n.º 2
0
 def test_results_are_also_stored_in_internal_cache(self, cache):
     cache.clear_cache()
     id = cache.resolve(Country, only_id=True, code='NG')
     key = cache.generate_key(Country, only_id=True, code='NG')
     assert id != None \
        and id == cache._XRefResolver__cache[key]
Exemplo n.º 3
0
 def test_fails_when_filter_matches_multiple_records(self, cache):
     with pytest.raises(exc.MultipleResultsFound):
         id = cache.resolve(State, code='BC')
Exemplo n.º 4
0
 def test_ok_when_filter_matches_single_record(self, cache):
     id = cache.resolve(Country, code='NG')
     assert id != None and type(id) is uuid.UUID
Exemplo n.º 5
0
 def test_returns_id_when_only_id_TRUE(self, cache):
     cache.clear_cache()
     country_id = cache.resolve(Country, only_id=True, code='NG')
     assert country_id \
        and type(country_id) is uuid.UUID
Exemplo n.º 6
0
 def test_returns_object_when_only_id_FALSE(self, cache):
     cache.clear_cache()
     country = cache.resolve(Country, only_id=False, code='NG')
     assert country is not None \
        and country.id != 0 \
        and isinstance(country, Country)