1111from nose .tools import eq_
1212from PIL import Image
1313from pyquery import PyQuery as pq
14- from tower import strip_whitespace
1514from waffle .models import Switch
1615
1716import amo
3231from mkt .constants import APP_IMAGE_SIZES
3332from mkt .constants .ratingsbodies import RATINGS_BODIES
3433from mkt .developers .models import ActivityLog
34+ from mkt .site .fixtures import fixture
3535from mkt .webapps .models import (AddonExcludedRegion as AER , ContentRating ,
3636 ImageAsset )
3737
@@ -63,7 +63,8 @@ def get_section_url(addon, section, edit=False):
6363
6464
6565class TestEdit (amo .tests .TestCase ):
66- fixtures = ['base/apps' , 'base/users' , 'webapps/337141-steamcube' ]
66+ fixtures = fixture ('group_admin' , 'user_999' , 'user_admin' ,
67+ 'user_admin_group' , 'webapp_337141' )
6768
6869 def setUp (self ):
6970 self .webapp = self .get_webapp ()
@@ -116,7 +117,7 @@ def check_form_url(self, section):
116117
117118
118119class TestEditListingWebapp (TestEdit ):
119- fixtures = TestEdit . fixtures
120+ fixtures = fixture ( 'webapp_337141' )
120121
121122 @mock .patch .object (settings , 'APP_PREVIEW' , False )
122123 def test_apps_context (self ):
@@ -138,7 +139,6 @@ class TestEditBasic(TestEdit):
138139
139140 def setUp (self ):
140141 super (TestEditBasic , self ).setUp ()
141- Switch .objects .create (name = 'marketplace' , active = True )
142142 self .cat = Category .objects .create (name = 'Games' , type = amo .ADDON_WEBAPP )
143143 self .dtype = DEVICE_TYPES .keys ()[0 ]
144144 AddonCategory .objects .create (addon = self .webapp , category = self .cat )
@@ -151,8 +151,8 @@ def get_webapp(self):
151151 return Addon .objects .get (id = 337141 )
152152
153153 def get_dict (self , ** kw ):
154- result = {'device_types' : self .dtype , 'name ' : 'new name ' ,
155- 'slug' : 'test_slug' , ' summary' : 'new summary' ,
154+ result = {'device_types' : self .dtype , 'slug ' : 'test_slug ' ,
155+ 'summary' : 'new summary' ,
156156 'manifest_url' : self .get_webapp ().manifest_url ,
157157 'categories' : [self .cat .id ]}
158158 result .update (** kw )
@@ -170,20 +170,6 @@ def test_appslug_visible(self):
170170 eq_ (pq (r .content )('#slug_edit' ).remove ('a, em' ).text (),
171171 u'/\u2026 /%s' % self .webapp .app_slug )
172172
173- def test_edit_name_required (self ):
174- r = self .client .post (self .edit_url , self .get_dict (name = '' ))
175- self .assertFormError (r , 'form' , 'name' , 'This field is required.' )
176-
177- def test_edit_name_required_for_all_whitespace (self ):
178- r = self .client .post (self .edit_url , self .get_dict (name = ' \t \n ' ))
179- self .assertFormError (r , 'form' , 'name' , 'This field is required.' )
180-
181- def test_edit_name_max_length (self ):
182- r = self .client .post (self .edit_url , self .get_dict (name = 'x' * 129 ))
183- eq_ (list (r .context ['form' ].errors ['name' ]),
184- [('en-us' ,
185- 'Ensure this value has at most 128 characters (it has 129).' )])
186-
187173 def test_edit_slug_success (self ):
188174 data = self .get_dict ()
189175 r = self .client .post (self .edit_url , data )
@@ -233,8 +219,7 @@ def test_view_manifest_url_default(self, mock_urlopen):
233219
234220 def test_view_edit_manifest_url_empty (self ):
235221 # Empty manifest should throw an error.
236- url = ''
237- r = self .client .post (self .edit_url , self .get_dict (manifest_url = url ))
222+ r = self .client .post (self .edit_url , self .get_dict (manifest_url = '' ))
238223 form = r .context ['form' ]
239224 assert 'manifest_url' in form .errors
240225 assert 'This field is required' in form .errors ['manifest_url' ][0 ]
@@ -362,31 +347,13 @@ def test_edit_summary_max_length(self):
362347 [('en-us' ,
363348 'Ensure this value has at most 250 characters (it has 251).' )])
364349
365- def test_edit (self ):
366- old_name = self .webapp .name
367- data = self .get_dict ()
368-
369- r = self .client .post (self .edit_url , data )
370- eq_ (r .status_code , 200 )
371- webapp = self .get_webapp ()
372-
373- eq_ (unicode (webapp .name ), data ['name' ])
374- eq_ (webapp .name .id , old_name .id )
375- eq_ (unicode (webapp .app_slug ), data ['slug' ])
376- eq_ (unicode (webapp .summary ), data ['summary' ])
377-
378350 def test_edit_check_description (self ):
379351 # Make sure bug 629779 doesn't return.
380352 r = self .client .post (self .edit_url , self .get_dict ())
381353 eq_ (r .status_code , 200 )
382354
383355 eq_ (self .get_webapp ().description , self .webapp .description )
384356
385- def test_edit_slug_invalid (self ):
386- r = self .client .post (self .edit_url ,
387- self .get_dict (name = '' , slug = 'invalid' ))
388- eq_ (pq (r .content )('form' ).attr ('action' ), self .edit_url )
389-
390357 def test_edit_slug_valid (self ):
391358 old_edit = self .edit_url
392359 data = self .get_dict (slug = 'valid' )
@@ -423,7 +390,6 @@ def test_edit_as_developer(self):
423390 eq_ (r .status_code , 200 )
424391 webapp = self .get_webapp ()
425392
426- eq_ (unicode (webapp .name ), data ['name' ])
427393 eq_ (unicode (webapp .app_slug ), data ['slug' ])
428394 eq_ (unicode (webapp .summary ), data ['summary' ])
429395
@@ -473,6 +439,7 @@ def test_refresh_dev_only(self, fetch):
473439
474440
475441class TestEditMedia (TestEdit ):
442+ fixtures = fixture ('webapp_337141' )
476443
477444 def setUp (self ):
478445 super (TestEditMedia , self ).setUp ()
@@ -501,7 +468,7 @@ def formset_media(self, prev_blank=None, *args, **kw):
501468 kw .setdefault ('initial_count' , 0 )
502469 kw .setdefault ('prefix' , 'files' )
503470
504- # Preview formset
471+ # Preview formset.
505472 fs = formset (* list (args ) + [self .formset_new_form (** prev_blank )], ** kw )
506473
507474 # Image asset formset
@@ -570,14 +537,14 @@ def test_edit_uploadedicon(self):
570537 self .assertNoFormErrors (r )
571538 webapp = self .get_webapp ()
572539
573- # Unfortunate hardcoding of URL
540+ # Unfortunate hardcoding of URL.
574541 url = webapp .get_icon_url (64 )
575542 assert ('addon_icons/%s/%s' % (webapp .id / 1000 , webapp .id )) in url , (
576543 'Unexpected path: %r' % url )
577544
578545 eq_ (data ['icon_type' ], 'image/png' )
579546
580- # Check that it was actually uploaded
547+ # Check that it was actually uploaded.
581548 dirname = os .path .join (settings .ADDON_ICONS_PATH ,
582549 '%s' % (webapp .id / 1000 ))
583550 dest = os .path .join (dirname , '%s-32.png' % webapp .id )
@@ -612,14 +579,14 @@ def test_edit_uploadedicon_noresize(self):
612579 self .assertNoFormErrors (r )
613580 webapp = self .get_webapp ()
614581
615- # Unfortunate hardcoding of URL
582+ # Unfortunate hardcoding of URL.
616583 addon_url = webapp .get_icon_url (64 ).split ('?' )[0 ]
617584 end = 'addon_icons/%s/%s-64.png' % (webapp .id / 1000 , webapp .id )
618585 assert addon_url .endswith (end ), 'Unexpected path: %r' % addon_url
619586
620587 eq_ (data ['icon_type' ], 'image/png' )
621588
622- # Check that it was actually uploaded
589+ # Check that it was actually uploaded.
623590 dirname = os .path .join (settings .ADDON_ICONS_PATH ,
624591 '%s' % (webapp .id / 1000 ))
625592 dest = os .path .join (dirname , '%s-64.png' % webapp .id )
@@ -941,6 +908,7 @@ def test_screenshot_with_icon(self):
941908
942909
943910class TestEditDetails (TestEdit ):
911+ fixtures = fixture ('webapp_337141' )
944912
945913 def setUp (self ):
946914 super (TestEditDetails , self ).setUp ()
@@ -1028,7 +996,7 @@ def test_edit_default_locale_required_trans(self):
1028996 r = self .client .post (self .edit_url , data )
1029997 self .assertFormError (r , 'form' , None , missing (fields ))
1030998
1031- # Now we're sending an fr description with the form.
999+ # Now we're sending an pt-BR description with the form.
10321000 data ['description_pt-BR' ] = 'pt-BR description'
10331001 r = self .client .post (self .edit_url , data )
10341002 self .assertNoFormErrors (r )
@@ -1069,6 +1037,7 @@ def test_games_already_excluded_in_brazil(self):
10691037
10701038
10711039class TestEditSupport (TestEdit ):
1040+ fixtures = fixture ('webapp_337141' )
10721041
10731042 def setUp (self ):
10741043 super (TestEditSupport , self ).setUp ()
@@ -1113,7 +1082,7 @@ def test_edit_support_url_optional(self):
11131082
11141083
11151084class TestEditTechnical (TestEdit ):
1116- fixtures = TestEdit . fixtures
1085+ fixtures = fixture ( 'webapp_337141' )
11171086
11181087 def setUp (self ):
11191088 super (TestEditTechnical , self ).setUp ()
@@ -1170,6 +1139,7 @@ def test_public_stats(self):
11701139
11711140
11721141class TestAdmin (TestEdit ):
1142+ fixtures = TestEdit .fixtures
11731143
11741144 def setUp (self ):
11751145 super (TestAdmin , self ).setUp ()
@@ -1189,6 +1159,7 @@ def log_in_with(self, rules):
11891159
11901160
11911161class TestAdminSettings (TestAdmin ):
1162+ fixtures = TestEdit .fixtures
11921163
11931164 def test_form_url (self ):
11941165 self .check_form_url ('admin' )
@@ -1333,6 +1304,7 @@ def test_ratings_view(self):
13331304
13341305
13351306class TestPromoUpload (TestAdmin ):
1307+ fixtures = TestEdit .fixtures
13361308
13371309 def post (self , ** kw ):
13381310 data = {'caption' : 'ball so hard that ish cray' ,
0 commit comments