<s> from . testmodels import EmailModel <EOL> from django . db . models import F <EOL> from django . test import TestCase <EOL> class TransactionTest ( TestCase ) : <EOL> emails = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> EmailModel ( email = self . emails [ <NUM_LIT:0> ] , number = <NUM_LIT:1> ) . save ( ) <EOL> EmailModel ( email = self . emails [ <NUM_LIT:0> ] , number = <NUM_LIT:2> ) . save ( ) <EOL> EmailModel ( email = self . emails [ <NUM_LIT:1> ] , number = <NUM_LIT:3> ) . save ( ) <EOL> def test_update ( self ) : <EOL> self . assertEqual ( <NUM_LIT:2> , len ( EmailModel . objects . all ( ) . filter ( <EOL> email = self . emails [ <NUM_LIT:0> ] ) ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( EmailModel . objects . all ( ) . filter ( <EOL> email = self . emails [ <NUM_LIT:1> ] ) ) ) <EOL> EmailModel . objects . all ( ) . filter ( email = self . emails [ <NUM_LIT:0> ] ) . update ( <EOL> email = self . emails [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( EmailModel . objects . all ( ) . filter ( <EOL> email = self . emails [ <NUM_LIT:0> ] ) ) ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( EmailModel . objects . all ( ) . filter ( <EOL> email = self . emails [ <NUM_LIT:1> ] ) ) ) <EOL> def test_f_object_updates ( self ) : <EOL> self . assertEqual ( <NUM_LIT:1> , len ( EmailModel . objects . all ( ) . filter ( <EOL> number = <NUM_LIT:1> ) ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( EmailModel . objects . all ( ) . filter ( <EOL> number = <NUM_LIT:2> ) ) ) <EOL> EmailModel . objects . all ( ) . filter ( email = self . emails [ <NUM_LIT:0> ] ) . update ( number = <EOL> F ( '<STR_LIT>' ) + F ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( EmailModel . objects . all ( ) . filter ( <EOL> number = <NUM_LIT:2> ) ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( EmailModel . objects . all ( ) . filter ( <EOL> number = <NUM_LIT:4> ) ) ) <EOL> EmailModel . objects . all ( ) . filter ( email = self . emails [ <NUM_LIT:1> ] ) . update ( number = <EOL> F ( '<STR_LIT>' ) + <NUM_LIT:10> , email = self . emails [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( EmailModel . objects . all ( ) . filter ( number = <NUM_LIT> ) ) ) <EOL> self . assertEqual ( self . emails [ <NUM_LIT:0> ] , EmailModel . objects . all ( ) . get ( number = <NUM_LIT> ) . <EOL> email ) <EOL> EmailModel . objects . all ( ) . filter ( number = <NUM_LIT> ) . update ( number = <EOL> F ( '<STR_LIT>' ) * ( F ( '<STR_LIT>' ) + <NUM_LIT:10> ) - <NUM_LIT:5> , email = self . emails [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( EmailModel . objects . all ( ) . filter ( number = <NUM_LIT> ) ) ) </s>
