<s> """<STR_LIT>""" <EOL> from tests import case <EOL> class ResultResourceTest ( case . api . ApiTestCase ) : <EOL> @ property <EOL> def factory ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . F . RunCaseVersionFactory <EOL> @ property <EOL> def resource_name ( self ) : <EOL> return "<STR_LIT:result>" <EOL> def test_submit_results_for_run ( self ) : <EOL> """<STR_LIT>""" <EOL> user = self . F . UserFactory . create ( <EOL> username = "<STR_LIT:foo>" , <EOL> permissions = [ "<STR_LIT>" ] , <EOL> ) <EOL> apikey = self . F . ApiKeyFactory . create ( owner = user ) <EOL> envs = self . F . EnvironmentFactory . create_full_set ( <EOL> { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } ) <EOL> pv = self . F . ProductVersionFactory . create ( environments = envs ) <EOL> r1 = self . F . RunFactory . create ( name = "<STR_LIT>" , productversion = pv ) <EOL> c_p = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> c_i = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> c_f = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> c_b = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> c_s = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> self . F . CaseStepFactory ( caseversion = c_f ) <EOL> self . factory . create ( caseversion = c_p , run = r1 , environments = envs ) <EOL> self . factory . create ( caseversion = c_i , run = r1 , environments = envs ) <EOL> self . factory . create ( caseversion = c_f , run = r1 , environments = envs ) <EOL> self . factory . create ( caseversion = c_b , run = r1 , environments = envs ) <EOL> self . factory . create ( caseversion = c_s , run = r1 , environments = envs ) <EOL> params = { "<STR_LIT:username>" : user . username , "<STR_LIT>" : apikey . key } <EOL> payload = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : c_p . case . id , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT>" : c_s . case . id , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT>" : c_i . case . id , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT>" : c_b . case . id , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : c_f . case . id , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:1> <EOL> } <EOL> ] <EOL> } <EOL> res = self . patch ( <EOL> self . get_list_url ( self . resource_name ) , <EOL> params = params , <EOL> payload = payload , <EOL> ) <EOL> result = self . model . Result . objects . get ( runcaseversion__caseversion = c_p ) <EOL> self . assertEqual ( result . status , "<STR_LIT>" ) <EOL> self . assertEqual ( result . environment , envs [ <NUM_LIT:0> ] ) <EOL> result = self . model . Result . objects . get ( runcaseversion__caseversion = c_f ) <EOL> self . assertEqual ( result . status , "<STR_LIT>" ) <EOL> self . assertEqual ( result . comment , "<STR_LIT>" ) <EOL> self . assertEqual ( set ( result . bug_urls ( ) ) , set ( [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( result . environment , envs [ <NUM_LIT:0> ] ) <EOL> result = self . model . Result . objects . get ( runcaseversion__caseversion = c_i ) <EOL> self . assertEqual ( result . status , "<STR_LIT>" ) <EOL> self . assertEqual ( result . environment , envs [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( result . comment , "<STR_LIT>" ) <EOL> def test_submit_results_for_run_no_status ( self ) : <EOL> """<STR_LIT>""" <EOL> user = self . F . UserFactory . create ( <EOL> username = "<STR_LIT:foo>" , <EOL> permissions = [ "<STR_LIT>" ] , <EOL> ) <EOL> apikey = self . F . ApiKeyFactory . create ( owner = user ) <EOL> envs = self . F . EnvironmentFactory . create_full_set ( <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> pv = self . F . ProductVersionFactory . create ( environments = envs ) <EOL> r1 = self . F . RunFactory . create ( name = "<STR_LIT>" , productversion = pv ) <EOL> c_p = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> self . factory . create ( caseversion = c_p , run = r1 ) <EOL> params = { "<STR_LIT:username>" : user . username , "<STR_LIT>" : apikey . key } <EOL> payload = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : c_p . case . id , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> } <EOL> ] <EOL> } <EOL> res = self . patch ( <EOL> self . get_list_url ( self . resource_name ) , <EOL> params = params , <EOL> payload = payload , <EOL> status = <NUM_LIT> , <EOL> ) <EOL> def test_submit_results_for_run_bad_env_id ( self ) : <EOL> """<STR_LIT>""" <EOL> user = self . F . UserFactory . create ( <EOL> username = "<STR_LIT:foo>" , <EOL> permissions = [ "<STR_LIT>" ] , <EOL> ) <EOL> apikey = self . F . ApiKeyFactory . create ( owner = user ) <EOL> envs = self . F . EnvironmentFactory . create_full_set ( <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> pv = self . F . ProductVersionFactory . create ( environments = envs ) <EOL> r1 = self . F . RunFactory . create ( name = "<STR_LIT>" , productversion = pv ) <EOL> c_p = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> self . factory . create ( caseversion = c_p , run = r1 ) <EOL> params = { "<STR_LIT:username>" : user . username , "<STR_LIT>" : apikey . key } <EOL> payload = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : c_p . case . id , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id + <NUM_LIT:1> , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" , <EOL> } <EOL> ] <EOL> } <EOL> res = self . patch ( <EOL> self . get_list_url ( self . resource_name ) , <EOL> params = params , <EOL> payload = payload , <EOL> status = <NUM_LIT> , <EOL> ) <EOL> def test_submit_results_for_run_no_runcaseversion ( self ) : <EOL> """<STR_LIT>""" <EOL> user = self . F . UserFactory . create ( <EOL> username = "<STR_LIT:foo>" , <EOL> permissions = [ "<STR_LIT>" ] , <EOL> ) <EOL> apikey = self . F . ApiKeyFactory . create ( owner = user ) <EOL> envs = self . F . EnvironmentFactory . create_full_set ( <EOL> { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } ) <EOL> pv = self . F . ProductVersionFactory . create ( environments = envs ) <EOL> r1 = self . F . RunFactory . create ( name = "<STR_LIT>" , productversion = pv ) <EOL> c_p = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> params = { "<STR_LIT:username>" : user . username , "<STR_LIT>" : apikey . key } <EOL> payload = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : c_p . case . id , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } , <EOL> ] <EOL> } <EOL> res = self . patch ( <EOL> self . get_list_url ( self . resource_name ) , <EOL> params = params , <EOL> payload = payload , <EOL> status = <NUM_LIT> , <EOL> ) <EOL> def test_submit_results_for_run_no_authentication ( self ) : <EOL> """<STR_LIT>""" <EOL> envs = self . F . EnvironmentFactory . create_full_set ( <EOL> { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } ) <EOL> pv = self . F . ProductVersionFactory . create ( environments = envs ) <EOL> r1 = self . F . RunFactory . create ( name = "<STR_LIT>" , productversion = pv ) <EOL> c_p = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> self . factory . create ( caseversion = c_p , run = r1 ) <EOL> payload = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : c_p . case . id , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } <EOL> ] <EOL> } <EOL> res = self . patch ( <EOL> self . get_list_url ( self . resource_name ) , <EOL> payload = payload , <EOL> status = <NUM_LIT> , <EOL> ) <EOL> def test_submit_results_for_run_no_authorization ( self ) : <EOL> """<STR_LIT>""" <EOL> user = self . F . UserFactory . create ( <EOL> username = "<STR_LIT:foo>" , <EOL> ) <EOL> apikey = self . F . ApiKeyFactory . create ( owner = user ) <EOL> envs = self . F . EnvironmentFactory . create_full_set ( <EOL> { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } ) <EOL> pv = self . F . ProductVersionFactory . create ( environments = envs ) <EOL> r1 = self . F . RunFactory . create ( name = "<STR_LIT>" , productversion = pv ) <EOL> c_p = self . F . CaseVersionFactory . create ( <EOL> case__product = pv . product , <EOL> productversion = pv , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> self . factory . create ( caseversion = c_p , run = r1 ) <EOL> params = { "<STR_LIT:username>" : user . username , "<STR_LIT>" : apikey . key } <EOL> payload = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : c_p . case . id , <EOL> "<STR_LIT>" : envs [ <NUM_LIT:0> ] . id , <EOL> "<STR_LIT>" : r1 . id , <EOL> "<STR_LIT:status>" : "<STR_LIT>" <EOL> } <EOL> ] <EOL> } <EOL> res = self . patch ( <EOL> self . get_list_url ( self . resource_name ) , <EOL> payload = payload , <EOL> params = params , <EOL> status = <NUM_LIT> , <EOL> ) </s>
