<s> import pytest <EOL> import pprint <EOL> from . . helpers . movie_data import Movie , Actor , Director <EOL> from . fixtures import backend , Movie <EOL> def test_multiple_joins ( backend ) : <EOL> francis_coppola = Director ( { '<STR_LIT:name>' : '<STR_LIT>' } ) <EOL> backend . save ( francis_coppola ) <EOL> al_pacino = Actor ( { '<STR_LIT:name>' : '<STR_LIT>' } ) <EOL> the_godfather = Movie ( { '<STR_LIT:title>' : '<STR_LIT>' , '<STR_LIT>' : francis_coppola } ) <EOL> al_pacino . movies = [ the_godfather ] <EOL> backend . save ( the_godfather ) <EOL> backend . update ( the_godfather , { '<STR_LIT>' : al_pacino } ) <EOL> result = backend . filter ( Movie , { '<STR_LIT>' : francis_coppola . name , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert the_godfather in result <EOL> result = backend . filter ( Movie , { '<STR_LIT>' : { '<STR_LIT>' : [ francis_coppola . name , '<STR_LIT>' ] } } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert the_godfather in result <EOL> result = backend . filter ( Movie , { '<STR_LIT>' : { '<STR_LIT>' : [ ] } } ) <EOL> assert len ( result ) == <NUM_LIT:0> <EOL> def test_basics ( backend ) : <EOL> francis_coppola = Director ( { '<STR_LIT:name>' : '<STR_LIT>' } ) <EOL> backend . save ( francis_coppola ) <EOL> the_godfather = Movie ( { '<STR_LIT:title>' : '<STR_LIT>' , '<STR_LIT>' : francis_coppola } ) <EOL> apocalypse_now = Movie ( { '<STR_LIT:title>' : '<STR_LIT>' } ) <EOL> star_wars_v = Movie ( { '<STR_LIT:title>' : '<STR_LIT>' } ) <EOL> backend . save ( the_godfather ) <EOL> backend . save ( apocalypse_now ) <EOL> marlon_brando = Actor ( { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : [ the_godfather , apocalypse_now ] } ) <EOL> al_pacino = Actor ( { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : [ the_godfather ] } ) <EOL> francis_coppola . favorite_actor = al_pacino <EOL> backend . save ( marlon_brando ) <EOL> backend . save ( al_pacino ) <EOL> backend . save ( francis_coppola ) <EOL> backend . commit ( ) <EOL> result = backend . filter ( Movie , { '<STR_LIT>' : francis_coppola . name } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert the_godfather in result <EOL> result = backend . filter ( Movie , { '<STR_LIT>' : { '<STR_LIT>' : [ francis_coppola . name , '<STR_LIT>' ] } } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert the_godfather in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ the_godfather , apocalypse_now ] } } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert marlon_brando in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ the_godfather , apocalypse_now ] } } ) <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> assert marlon_brando in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : { '<STR_LIT:title>' : '<STR_LIT>' } } } ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ { '<STR_LIT>' : { '<STR_LIT:title>' : '<STR_LIT>' } } , { '<STR_LIT>' : { '<STR_LIT:title>' : '<STR_LIT>' } } ] } } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert marlon_brando in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ the_godfather , apocalypse_now ] } } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert marlon_brando in result <EOL> assert al_pacino not in result <EOL> with pytest . raises ( AttributeError ) : <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : [ the_godfather , apocalypse_now ] } ) <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ the_godfather , apocalypse_now ] } } ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' ] } } ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' ] } } ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } } ) <EOL> assert len ( result ) == <NUM_LIT:0> <EOL> result = backend . filter ( Actor , { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> assert marlon_brando in result <EOL> assert al_pacino in result <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> result = backend . filter ( Movie , { '<STR_LIT>' : francis_coppola } ) <EOL> assert len ( result ) == <NUM_LIT:1> <EOL> assert the_godfather in result </s>
