2323 AddonDeviceType , AddonUser , Category , DeviceType )
2424from bandwagon .models import Collection , CollectionAddon , FeaturedCollection
2525from mkt .developers .models import ActivityLog
26- from tags .models import Tag , AddonTag
2726from users .models import UserProfile
2827
2928
@@ -53,10 +52,6 @@ def setUp(self):
5352 self .url = addon .get_dev_url ()
5453 self .user = UserProfile .objects .get (pk = 55021 )
5554
56- self .tags = ['tag3' , 'tag2' , 'tag1' ]
57- for t in self .tags :
58- Tag (tag_text = t ).save_tag (addon )
59-
6055 self .addon = self .get_addon ()
6156
6257 def get_addon (self ):
@@ -68,8 +63,7 @@ def get_url(self, section, edit=False):
6863 def get_dict (self , ** kw ):
6964 fs = formset (self .cat_initial , initial_count = 1 )
7065 result = {'name' : 'new name' , 'slug' : 'test_slug' ,
71- 'summary' : 'new summary' ,
72- 'tags' : ', ' .join (self .tags )}
66+ 'summary' : 'new summary' }
7367 result .update (** kw )
7468 result .update (fs )
7569 return result
@@ -266,8 +260,6 @@ def test_edit(self):
266260 eq_ (unicode (addon .slug ), data ['slug' ])
267261 eq_ (unicode (addon .summary ), data ['summary' ])
268262
269- eq_ ([unicode (t ) for t in addon .tags .all ()], sorted (self .tags ))
270-
271263 def test_edit_check_description (self ):
272264 # Make sure bug 629779 doesn't return.
273265 old_desc = self .addon .description
@@ -330,8 +322,6 @@ def test_edit_as_developer(self):
330322 eq_ (unicode (addon .slug ), data ['slug' ])
331323 eq_ (unicode (addon .summary ), data ['summary' ])
332324
333- eq_ ([unicode (t ) for t in addon .tags .all ()], sorted (self .tags ))
334-
335325 def test_edit_name_required (self ):
336326 data = self .get_dict (name = '' , slug = 'test_addon' )
337327 r = self .client .post (self .basic_edit_url , data )
@@ -351,104 +341,6 @@ def test_edit_slugs_unique(self):
351341 eq_ (r .status_code , 200 )
352342 self .assertFormError (r , 'form' , 'slug' , 'This slug is already in use.' )
353343
354- def test_edit_add_tag (self ):
355- count = ActivityLog .objects .all ().count ()
356- self .tags .insert (0 , 'tag4' )
357- data = self .get_dict ()
358- r = self .client .post (self .basic_edit_url , data )
359- eq_ (r .status_code , 200 )
360-
361- result = pq (r .content )('#addon_tags_edit' ).eq (0 ).text ()
362-
363- eq_ (result , ', ' .join (sorted (self .tags )))
364- eq_ ((ActivityLog .objects .for_addons (self .addon )
365- .get (action = amo .LOG .ADD_TAG .id )).to_string (),
366- '<a href="/en-US/firefox/tag/tag4">tag4</a> added to '
367- '<a href="/en-US/firefox/addon/test_slug/">new name</a>.' )
368- eq_ (ActivityLog .objects .filter (action = amo .LOG .ADD_TAG .id ).count (),
369- count + 1 )
370-
371- def test_edit_blacklisted_tag (self ):
372- Tag .objects .get_or_create (tag_text = 'blue' , blacklisted = True )
373- data = self .get_dict (tags = 'blue' )
374- r = self .client .post (self .basic_edit_url , data )
375- eq_ (r .status_code , 200 )
376-
377- error = 'Invalid tag: blue'
378- self .assertFormError (r , 'form' , 'tags' , error )
379-
380- def test_edit_blacklisted_tags_2 (self ):
381- Tag .objects .get_or_create (tag_text = 'blue' , blacklisted = True )
382- Tag .objects .get_or_create (tag_text = 'darn' , blacklisted = True )
383- data = self .get_dict (tags = 'blue, darn, swearword' )
384- r = self .client .post (self .basic_edit_url , data )
385- eq_ (r .status_code , 200 )
386-
387- error = 'Invalid tags: blue, darn'
388- self .assertFormError (r , 'form' , 'tags' , error )
389-
390- def test_edit_blacklisted_tags_3 (self ):
391- Tag .objects .get_or_create (tag_text = 'blue' , blacklisted = True )
392- Tag .objects .get_or_create (tag_text = 'darn' , blacklisted = True )
393- Tag .objects .get_or_create (tag_text = 'swearword' , blacklisted = True )
394- data = self .get_dict (tags = 'blue, darn, swearword' )
395- r = self .client .post (self .basic_edit_url , data )
396- eq_ (r .status_code , 200 )
397-
398- error = 'Invalid tags: blue, darn, swearword'
399- self .assertFormError (r , 'form' , 'tags' , error )
400-
401- def test_edit_remove_tag (self ):
402- self .tags .remove ('tag2' )
403-
404- count = ActivityLog .objects .all ().count ()
405- data = self .get_dict ()
406- r = self .client .post (self .basic_edit_url , data )
407- eq_ (r .status_code , 200 )
408-
409- result = pq (r .content )('#addon_tags_edit' ).eq (0 ).text ()
410-
411- eq_ (result , ', ' .join (sorted (self .tags )))
412-
413- eq_ (ActivityLog .objects .filter (action = amo .LOG .REMOVE_TAG .id ).count (),
414- count + 1 )
415-
416- def test_edit_minlength_tags (self ):
417- tags = self .tags
418- tags .append ('a' * (amo .MIN_TAG_LENGTH - 1 ))
419- data = self .get_dict ()
420- r = self .client .post (self .basic_edit_url , data )
421- eq_ (r .status_code , 200 )
422-
423- self .assertFormError (r , 'form' , 'tags' ,
424- 'All tags must be at least %d characters.' %
425- amo .MIN_TAG_LENGTH )
426-
427- def test_edit_max_tags (self ):
428- tags = self .tags
429-
430- for i in range (amo .MAX_TAGS + 1 ):
431- tags .append ('test%d' % i )
432-
433- data = self .get_dict ()
434- r = self .client .post (self .basic_edit_url , data )
435- self .assertFormError (r , 'form' , 'tags' , 'You have %d too many tags.' %
436- (len (tags ) - amo .MAX_TAGS ))
437-
438- def test_edit_tag_empty_after_slug (self ):
439- start = Tag .objects .all ().count ()
440- data = self .get_dict (tags = '>>' )
441- self .client .post (self .basic_edit_url , data )
442-
443- # Check that the tag did not get created.
444- eq_ (start , Tag .objects .all ().count ())
445-
446- def test_edit_tag_slugified (self ):
447- data = self .get_dict (tags = '<script>alert("foo")</script>' )
448- self .client .post (self .basic_edit_url , data )
449- tag = Tag .objects .all ().order_by ('-pk' )[0 ]
450- eq_ (tag .tag_text , 'scriptalertfooscript' )
451-
452344 def test_edit_categories_add (self ):
453345 eq_ ([c .id for c in self .get_addon ().all_categories ], [22 ])
454346 self .cat_initial ['categories' ] = [22 , 23 ]
@@ -598,16 +490,6 @@ def test_edit_summary_max_length(self):
598490 'Ensure this value has at most 250 '
599491 'characters (it has 251).' )
600492
601- def test_edit_restricted_tags (self ):
602- addon = self .get_addon ()
603- tag = Tag .objects .create (tag_text = 'restartless' , restricted = True )
604- AddonTag .objects .create (tag = tag , addon = addon )
605-
606- res = self .client .get (self .basic_edit_url )
607- divs = pq (res .content )('#addon_tags_edit .edit-addon-details' )
608- eq_ (len (divs ), 2 )
609- assert 'restartless' in divs .eq (1 ).text ()
610-
611493 def test_text_not_none_when_has_flags (self ):
612494 r = self .client .get (self .url )
613495 doc = pq (r .content )
0 commit comments