<s> from . testmodels import FieldsWithOptionsModel , OrderedModel , SelfReferenceModel <EOL> import datetime <EOL> from django . test import TestCase <EOL> from django . core . exceptions import ObjectDoesNotExist , MultipleObjectsReturned <EOL> class NonReturnSetsTest ( TestCase ) : <EOL> floats = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> emails = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> for index , ( float , email ) in enumerate ( zip ( NonReturnSetsTest . floats , <EOL> NonReturnSetsTest . emails ) ) : <EOL> self . last_save_time = datetime . datetime . now ( ) . time ( ) <EOL> ordered_instance = OrderedModel ( priority = index , pk = index + <NUM_LIT:1> ) <EOL> ordered_instance . save ( ) <EOL> model = FieldsWithOptionsModel ( floating_point = float , <EOL> integer = int ( float ) , email = email , <EOL> time = self . last_save_time , <EOL> foreign_key = ordered_instance ) <EOL> model . save ( ) <EOL> def test_get ( self ) : <EOL> self . assertEquals ( FieldsWithOptionsModel . objects . get ( <EOL> email = '<STR_LIT>' ) <EOL> . email , '<STR_LIT>' ) <EOL> self . assertRaises ( MultipleObjectsReturned , FieldsWithOptionsModel . objects <EOL> . get , integer = <NUM_LIT:2> ) <EOL> self . assertRaises ( ObjectDoesNotExist , FieldsWithOptionsModel . objects <EOL> . get , floating_point = <NUM_LIT> ) <EOL> def test_count ( self ) : <EOL> self . assertEquals ( FieldsWithOptionsModel . objects . filter ( <EOL> integer = <NUM_LIT:2> ) . count ( ) , <NUM_LIT:2> ) <EOL> def test_in_bulk ( self ) : <EOL> self . assertEquals ( [ key in [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> for key in FieldsWithOptionsModel . objects . in_bulk ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] ) . keys ( ) ] , <EOL> [ True , ] * <NUM_LIT:2> ) <EOL> def test_latest ( self ) : <EOL> self . assertEquals ( '<STR_LIT>' , FieldsWithOptionsModel . objects <EOL> . latest ( '<STR_LIT:time>' ) . email ) <EOL> def test_exists ( self ) : <EOL> self . assertEquals ( True , FieldsWithOptionsModel . objects . exists ( ) ) <EOL> def test_deletion ( self ) : <EOL> self . assertEquals ( FieldsWithOptionsModel . objects . count ( ) , <NUM_LIT:5> ) <EOL> FieldsWithOptionsModel . objects . get ( email = '<STR_LIT>' ) . delete ( ) <EOL> self . assertEquals ( FieldsWithOptionsModel . objects . count ( ) , <NUM_LIT:4> ) <EOL> FieldsWithOptionsModel . objects . filter ( email__in = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , ] ) . delete ( ) <EOL> self . assertEquals ( FieldsWithOptionsModel . objects . count ( ) , <NUM_LIT:2> ) <EOL> def test_selfref_deletion ( self ) : <EOL> entity = SelfReferenceModel ( ) <EOL> entity . save ( ) <EOL> entity . delete ( ) <EOL> def test_foreign_key_fetch ( self ) : <EOL> ordered_instance = OrderedModel . objects . get ( priority = <NUM_LIT:2> ) <EOL> self . assertEquals ( FieldsWithOptionsModel . objects . get ( integer = <NUM_LIT:9> ) . foreign_key , <EOL> ordered_instance ) <EOL> def test_foreign_key_backward ( self ) : <EOL> entity = OrderedModel . objects . all ( ) [ <NUM_LIT:0> ] <EOL> self . assertEquals ( entity . keys . count ( ) , <NUM_LIT:1> ) <EOL> new_foreign_key = FieldsWithOptionsModel ( floating_point = <NUM_LIT> , integer = <NUM_LIT:3> , <EOL> email = '<STR_LIT>' , time = datetime . datetime . now ( ) ) <EOL> entity . keys . add ( new_foreign_key ) <EOL> self . assertEquals ( entity . keys . count ( ) , <NUM_LIT:2> ) <EOL> entity . keys . remove ( new_foreign_key ) <EOL> self . assertEquals ( entity . keys . count ( ) , <NUM_LIT:1> ) <EOL> entity . keys . clear ( ) <EOL> self . assertTrue ( not entity . keys . exists ( ) ) <EOL> entity . keys = [ new_foreign_key , new_foreign_key ] <EOL> self . assertEquals ( entity . keys . count ( ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( entity . keys . all ( ) [ <NUM_LIT:0> ] . integer , <NUM_LIT:3> ) </s>
