def test_resolve_target_object_method(): handler = Handler(dehydrator=None, spec=None) handler.dehydrator = stub(GETTER_PREFIX='get_') obj = stub(username=lambda: 'joker') target = handler.resolve_target(obj=obj, target='username') assert target == 'joker'
def test_resolve_target_object_attribute(): handler = Handler(dehydrator=None, spec=DUMMY_SPEC) handler.dehydrator = stub(GETTER_PREFIX='get_') obj = stub(username='******') target = handler.resolve_target(obj=obj, target='username') assert target == 'joker'
def test_resolve_target_cant_be_resolved(): handler = Handler(dehydrator=None, spec=DUMMY_SPEC) handler.dehydrator = stub(GETTER_PREFIX='get_') with pytest.raises(DehydrationException): handler.resolve_target(obj=None, target='username')
def test_resolve_target_cant_be_resolved(): handler = Handler(dehydrator=None, spec=DUMMY_SPEC) handler.dehydrator = stub(GETTER_PREFIX='get_') with pytest.raises(DehydrationException): handler.resolve_target(obj=DUMMY_OBJECT, target='username')