<s> from sondra . document . valuehandlers import DateTime , Geometry , Now <EOL> from shapely . geometry import Point <EOL> from datetime import datetime <EOL> import rethinkdb as r <EOL> import pytest <EOL> from sondra . tests . api import * <EOL> from sondra . auth import Auth <EOL> s = ConcreteSuite ( ) <EOL> api = SimpleApp ( s ) <EOL> auth = Auth ( s ) <EOL> AuthenticatedApp ( s ) <EOL> AuthorizedApp ( s ) <EOL> s . ensure_database_objects ( ) <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def simple_doc ( request ) : <EOL> simple_doc = s [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create ( { <EOL> '<STR_LIT:name>' : "<STR_LIT>" , <EOL> "<STR_LIT:date>" : datetime . now ( ) , <EOL> "<STR_LIT:value>" : <NUM_LIT:0> <EOL> } ) <EOL> def teardown ( ) : <EOL> simple_doc . delete ( ) <EOL> request . addfinalizer ( teardown ) <EOL> return simple_doc <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def fk_doc ( request , simple_doc ) : <EOL> fk_doc = s [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create ( { <EOL> '<STR_LIT:name>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : simple_doc , <EOL> '<STR_LIT>' : [ simple_doc ] <EOL> } ) <EOL> def teardown ( ) : <EOL> fk_doc . delete ( ) <EOL> request . addfinalizer ( teardown ) <EOL> return fk_doc <EOL> def test_foreignkey ( fk_doc , simple_doc ) : <EOL> retr_doc = s [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> assert isinstance ( fk_doc . obj [ '<STR_LIT>' ] , str ) <EOL> assert fk_doc . obj [ '<STR_LIT>' ] == simple_doc . url <EOL> assert isinstance ( retr_doc . obj [ '<STR_LIT>' ] , str ) <EOL> assert retr_doc . obj [ '<STR_LIT>' ] == simple_doc . url <EOL> storage_repr = fk_doc . rql_repr ( ) <EOL> assert storage_repr [ '<STR_LIT>' ] == simple_doc . id <EOL> assert isinstance ( fk_doc [ '<STR_LIT>' ] , SimpleDocument ) </s>
