<s> from oslo_serialization import jsonutils <EOL> from nailgun . db . sqlalchemy . models . plugin_link import PluginLink <EOL> from nailgun . test . base import BaseIntegrationTest <EOL> from nailgun . utils import reverse <EOL> class TestHandlers ( BaseIntegrationTest ) : <EOL> def setUp ( self ) : <EOL> super ( TestHandlers , self ) . setUp ( ) <EOL> self . plugin = self . env . create_plugin ( api = False ) <EOL> self . plugin_link = self . env . create_plugin_link ( plugin_id = self . plugin . id ) <EOL> def test_plugin_link_update ( self ) : <EOL> plugin_link_update = { <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True <EOL> } <EOL> resp = self . app . put ( <EOL> reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . plugin [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : self . plugin_link . id } <EOL> ) , <EOL> jsonutils . dumps ( plugin_link_update ) , <EOL> headers = self . default_headers <EOL> ) <EOL> self . assertEqual ( self . plugin_link . id , resp . json_body [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , resp . json_body [ '<STR_LIT:title>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , resp . json_body [ '<STR_LIT:description>' ] ) <EOL> self . assertEqual ( True , resp . json_body [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( self . plugin_link . url , resp . json_body [ '<STR_LIT:url>' ] ) <EOL> def test_plugin_link_get_with_plugin ( self ) : <EOL> resp = self . app . get ( <EOL> reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . plugin [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : self . plugin_link . id } <EOL> ) , <EOL> headers = self . default_headers <EOL> ) <EOL> self . assertEqual ( <NUM_LIT:200> , resp . status_code ) <EOL> self . assertEqual ( self . plugin_link . id , resp . json_body [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( self . plugin_link . title , resp . json_body [ '<STR_LIT:title>' ] ) <EOL> self . assertEqual ( self . plugin_link . url , resp . json_body [ '<STR_LIT:url>' ] ) <EOL> self . assertEqual ( self . plugin_link . description , <EOL> resp . json_body [ '<STR_LIT:description>' ] ) <EOL> self . assertEqual ( self . plugin_link . hidden , resp . json_body [ '<STR_LIT>' ] ) <EOL> def test_plugin_link_not_found ( self ) : <EOL> resp = self . app . get ( <EOL> reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . plugin [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : self . plugin_link . id + <NUM_LIT:1> } <EOL> ) , <EOL> headers = self . default_headers , <EOL> expect_errors = True <EOL> ) <EOL> self . assertEqual ( <NUM_LIT> , resp . status_code ) <EOL> def test_plugin_link_delete ( self ) : <EOL> resp = self . app . delete ( <EOL> reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . plugin [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : self . plugin_link . id } <EOL> ) , <EOL> headers = self . default_headers , <EOL> ) <EOL> self . assertEqual ( <NUM_LIT> , resp . status_code ) <EOL> d_e_query = self . db . query ( PluginLink ) . filter_by ( plugin_id = self . plugin . id ) <EOL> self . assertEquals ( d_e_query . count ( ) , <NUM_LIT:0> ) <EOL> def test_plugin_link_patch ( self ) : <EOL> plugin_link_update = { <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True <EOL> } <EOL> resp = self . app . patch ( <EOL> reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . plugin [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : self . plugin_link . id } <EOL> ) , <EOL> jsonutils . dumps ( plugin_link_update ) , <EOL> headers = self . default_headers <EOL> ) <EOL> self . assertEqual ( self . plugin_link . id , resp . json_body [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , resp . json_body [ '<STR_LIT:title>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , resp . json_body [ '<STR_LIT:description>' ] ) <EOL> self . assertEqual ( self . plugin_link . url , resp . json_body [ '<STR_LIT:url>' ] ) <EOL> self . assertEqual ( True , resp . json_body [ '<STR_LIT>' ] ) </s>
