<s> from django . test import TestCase <EOL> from django . core . exceptions import ValidationError <EOL> from mozdns . srv . models import SRV <EOL> from mozdns . domain . models import Domain <EOL> class SRVTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . o = Domain ( name = "<STR_LIT>" ) <EOL> self . o . save ( ) <EOL> self . o_e = Domain ( name = "<STR_LIT>" ) <EOL> self . o_e . save ( ) <EOL> self . b_o_e = Domain ( name = "<STR_LIT>" ) <EOL> self . b_o_e . save ( ) <EOL> def do_generic_add ( self , data ) : <EOL> srv = SRV ( ** data ) <EOL> srv . __repr__ ( ) <EOL> srv . save ( ) <EOL> self . assertTrue ( srv . details ( ) ) <EOL> self . assertTrue ( srv . get_absolute_url ( ) ) <EOL> self . assertTrue ( srv . get_edit_url ( ) ) <EOL> self . assertTrue ( srv . get_delete_url ( ) ) <EOL> rsrv = SRV . objects . filter ( ** data ) <EOL> self . assertTrue ( len ( rsrv ) == <NUM_LIT:1> ) <EOL> return srv <EOL> def do_remove ( self , data ) : <EOL> srv = self . do_generic_add ( data ) <EOL> srv . delete ( ) <EOL> rsrv = SRV . objects . filter ( ** data ) <EOL> self . assertTrue ( len ( rsrv ) == <NUM_LIT:0> ) <EOL> def test_add_remove_srv ( self ) : <EOL> data = { '<STR_LIT:label>' : '<STR_LIT:*>' , '<STR_LIT>' : self . o_e , '<STR_LIT:target>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:port>' : <EOL> <NUM_LIT> } <EOL> self . do_remove ( data ) <EOL> data = { '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . o_e , <EOL> '<STR_LIT:target>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <EOL> <NUM_LIT> , '<STR_LIT:port>' : <NUM_LIT> } <EOL> self . do_remove ( data ) <EOL> data = { '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . o , '<STR_LIT:target>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:port>' : <NUM_LIT> } <EOL> self . do_remove ( data ) <EOL> data = { '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . b_o_e , <EOL> '<STR_LIT:target>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <EOL> <NUM_LIT> , '<STR_LIT:port>' : <NUM_LIT> } <EOL> self . do_remove ( data ) <EOL> data = { '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . o , '<STR_LIT:target>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:port>' : <NUM_LIT> } <EOL> self . do_remove ( data ) <EOL> data = { '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . o_e , '<STR_LIT:target>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:port>' : <EOL> <NUM_LIT> } <EOL> self . do_remove ( data ) <EOL> data = { '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . o_e , '<STR_LIT:target>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:port>' : <EOL> <NUM_LIT> } <EOL> self . do_remove ( data ) <EOL> def test_invalid_add_update ( self ) : <EOL> data = { '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . o_e , <EOL> '<STR_LIT:target>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <EOL> <NUM_LIT> , '<STR_LIT:port>' : <NUM_LIT> } <EOL> srv0 = self . do_generic_add ( data ) <EOL> self . assertRaises ( ValidationError , self . do_generic_add , data ) <EOL> data = { <EOL> '<STR_LIT:label>' : '<STR_LIT>' , '<STR_LIT>' : self . o_e , <EOL> '<STR_LIT:target>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT:port>' : <NUM_LIT> } <EOL> self . do_generic_add ( data ) <EOL> self . assertRaises ( ValidationError , self . do_generic_add , data ) <EOL> srv0 . target = "<STR_LIT>" <EOL> self . assertRaises ( ValidationError , srv0 . save ) <EOL> srv0 . port = <NUM_LIT> <EOL> self . assertRaises ( ValidationError , srv0 . save ) <EOL> srv0 . port = <NUM_LIT:1> <EOL> srv0 . priority = <NUM_LIT> <EOL> self . assertRaises ( ValidationError , srv0 . save ) <EOL> srv0 . priority = <NUM_LIT:1> <EOL> srv0 . weight = <NUM_LIT> <EOL> self . assertRaises ( ValidationError , srv0 . save ) <EOL> srv0 . target = "<STR_LIT>" <EOL> srv0 . label = "<STR_LIT>" <EOL> self . assertRaises ( ValidationError , srv0 . save ) <EOL> srv0 . target = "<STR_LIT>" <EOL> self . assertRaises ( ValidationError , srv0 . save ) </s>
