<s> from __future__ import absolute_import <EOL> from django . core . exceptions import FieldError <EOL> from django . test import TestCase <EOL> from . models import Author , Article <EOL> class CustomColumnsTests ( TestCase ) : <EOL> def test_db_column ( self ) : <EOL> a1 = Author . objects . create ( first_name = "<STR_LIT>" , last_name = "<STR_LIT>" ) <EOL> a2 = Author . objects . create ( first_name = "<STR_LIT>" , last_name = "<STR_LIT>" ) <EOL> art = Article . objects . create ( headline = "<STR_LIT>" ) <EOL> art . authors = [ a1 , a2 ] <EOL> self . assertQuerysetEqual ( <EOL> Author . objects . all ( ) , [ <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> ] , <EOL> unicode <EOL> ) <EOL> self . assertQuerysetEqual ( <EOL> Author . objects . filter ( first_name__exact = "<STR_LIT>" ) , [ <EOL> "<STR_LIT>" , <EOL> ] , <EOL> unicode <EOL> ) <EOL> self . assertEqual ( <EOL> Author . objects . get ( first_name__exact = "<STR_LIT>" ) , <EOL> a1 , <EOL> ) <EOL> self . assertRaises ( FieldError , <EOL> lambda : Author . objects . filter ( firstname__exact = "<STR_LIT>" ) <EOL> ) <EOL> a = Author . objects . get ( last_name__exact = "<STR_LIT>" ) <EOL> a . first_name = "<STR_LIT>" <EOL> a . last_name = "<STR_LIT>" <EOL> self . assertRaises ( AttributeError , lambda : a . firstname ) <EOL> self . assertRaises ( AttributeError , lambda : a . last ) <EOL> self . assertQuerysetEqual ( <EOL> art . authors . all ( ) , [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] , <EOL> unicode <EOL> ) <EOL> self . assertQuerysetEqual ( <EOL> a . article_set . all ( ) , [ <EOL> "<STR_LIT>" , <EOL> ] , <EOL> lambda a : a . headline <EOL> ) <EOL> self . assertQuerysetEqual ( <EOL> art . authors . filter ( last_name = '<STR_LIT>' ) , [ <EOL> "<STR_LIT>" <EOL> ] , <EOL> unicode <EOL> ) </s>
