Exemplo n.º 1
0
 def test_resolve_xref_gets_model_for_xref_field_ending_witout_id(self, cache):
     cache.clear_cache()
     data = {'country': 'NG'}
     session = cache._XRefResolver__dbsession
     imp = ValueReader(AttrDict(wb=None, db=session, cache=cache))
     imp.resolve_xref(data, ('country', 'code', Country))
     assert isinstance(data['country'], Country)
Exemplo n.º 2
0
 def test_resolve_xref_gets_id_for_xref_field_ending_with_id(self, cache):
     cache.clear_cache()
     data = {'country_id': 'NG'}
     session = cache._XRefResolver__dbsession
     imp = ValueReader(AttrDict(wb=None, db=session, cache=cache))
     imp.resolve_xref(data, ('country_id', 'code', Country))
     assert type(data['country_id']) is uuid.UUID
Exemplo n.º 3
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.º 4
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.º 5
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)