@@ -1961,6 +1961,7 @@ def setUp(self):
1961
1961
self .statsd_incr_mock = self .patch ('olympia.addons.serializers.statsd.incr' )
1962
1962
1963
1963
def test_basic (self ):
1964
+ original_summary = str (self .addon .summary )
1964
1965
response = self .request (data = {'summary' : {'en-US' : 'summary update!' }})
1965
1966
self .addon .reload ()
1966
1967
assert response .status_code == 200 , response .content
@@ -1990,8 +1991,12 @@ def test_basic(self):
1990
1991
)
1991
1992
).get ()
1992
1993
assert alog .user == self .user
1993
- assert alog .action == amo .LOG .EDIT_PROPERTIES .id
1994
- assert alog .details == ['summary' ]
1994
+ assert alog .action == amo .LOG .EDIT_ADDON_PROPERTY .id
1995
+ assert alog .arguments == [
1996
+ self .addon ,
1997
+ 'summary' ,
1998
+ json .dumps ({'removed' : [original_summary ], 'added' : ['summary update!' ]}),
1999
+ ]
1995
2000
return data
1996
2001
1997
2002
@override_settings (API_THROTTLING = False )
@@ -2212,6 +2217,10 @@ def test_set_slug_log(self):
2212
2217
def test_set_extra_data (self ):
2213
2218
self .addon .description = 'Existing description'
2214
2219
self .addon .save ()
2220
+ original_data = {
2221
+ 'name' : str (self .addon .name ),
2222
+ 'summary' : str (self .addon .summary ),
2223
+ }
2215
2224
patch_data = {
2216
2225
'developer_comments' : {'en-US' : 'comments' },
2217
2226
'homepage' : {'en-US' : 'https://my.home.page/' },
@@ -2251,17 +2260,48 @@ def test_set_extra_data(self):
2251
2260
assert addon .
support_email == '[email protected] '
2252
2261
assert data ['support_url' ]['url' ] == {'en-US' : 'https://my.home.page/support/' }
2253
2262
assert addon .support_url == 'https://my.home.page/support/'
2263
+
2264
+ summ_log , name_log = list (
2265
+ ActivityLog .objects .filter (action = amo .LOG .EDIT_ADDON_PROPERTY .id )
2266
+ )
2267
+ if name_log .arguments [1 ] != 'name' :
2268
+ # The order isn't deterministic, it doesn't matter, so just switch em.
2269
+ name_log , summ_log = summ_log , name_log
2270
+ assert name_log .arguments == [
2271
+ self .addon ,
2272
+ 'name' ,
2273
+ json .dumps (
2274
+ {
2275
+ 'removed' : [original_data ['name' ]],
2276
+ 'added' : [patch_data ['name' ]['en-US' ]],
2277
+ }
2278
+ ),
2279
+ ]
2280
+ assert summ_log .arguments == [
2281
+ self .addon ,
2282
+ 'summary' ,
2283
+ json .dumps (
2284
+ {
2285
+ 'removed' : [original_data ['summary' ]],
2286
+ 'added' : [patch_data ['summary' ]['en-US' ]],
2287
+ }
2288
+ ),
2289
+ ]
2290
+
2254
2291
alog = ActivityLog .objects .exclude (
2255
2292
action__in = (
2256
2293
amo .LOG .ADD_VERSION .id ,
2257
2294
amo .LOG .LOG_IN .id ,
2258
2295
amo .LOG .LOG_IN_API_TOKEN .id ,
2259
2296
amo .LOG .ADDON_SLUG_CHANGED .id ,
2297
+ amo .LOG .EDIT_ADDON_PROPERTY .id ,
2260
2298
)
2261
2299
).get ()
2262
2300
assert alog .user == self .user
2263
2301
assert alog .action == amo .LOG .EDIT_PROPERTIES .id
2264
- assert alog .details == list (patch_data .keys ())
2302
+ assert alog .details == [
2303
+ prop for prop in patch_data if prop not in ('name' , 'summary' )
2304
+ ]
2265
2305
2266
2306
def test_set_disabled (self ):
2267
2307
response = self .request (
@@ -2500,7 +2540,7 @@ def test_delete_icon_formdata(self):
2500
2540
2501
2541
def _test_metadata_content_review (self ):
2502
2542
response = self .request (
2503
- data = {'name' : {'en-US' : 'new name' }, 'summary' : {'en-US ' : 'new summary' }},
2543
+ data = {'name' : {'en-US' : 'new name' }, 'summary' : {'fr ' : 'summary nouveau ' }},
2504
2544
)
2505
2545
assert response .status_code == 200
2506
2546
@@ -2526,6 +2566,7 @@ def test_metadata_content_review_unlisted(self, fetch_mock):
2526
2566
)
2527
2567
2528
2568
def test_metadata_change_triggers_content_review (self ):
2569
+ old_name = str (self .addon .name )
2529
2570
AddonApprovalsCounter .approve_content_for_addon (addon = self .addon )
2530
2571
assert AddonApprovalsCounter .objects .get (addon = self .addon ).last_content_review
2531
2572
@@ -2539,6 +2580,26 @@ def test_metadata_change_triggers_content_review(self):
2539
2580
self .statsd_incr_mock .assert_any_call (
2540
2581
'addons.submission.metadata_content_review_triggered'
2541
2582
)
2583
+ assert (
2584
+ ActivityLog .objects .filter (action = amo .LOG .EDIT_ADDON_PROPERTY .id ).count ()
2585
+ == 2
2586
+ )
2587
+ summ_log , name_log = list (
2588
+ ActivityLog .objects .filter (action = amo .LOG .EDIT_ADDON_PROPERTY .id )
2589
+ )
2590
+ if name_log .arguments [1 ] != 'name' :
2591
+ # The order isn't deterministic, it doesn't matter, so just switch em.
2592
+ name_log , summ_log = summ_log , name_log
2593
+ assert name_log .arguments == [
2594
+ self .addon ,
2595
+ 'name' ,
2596
+ json .dumps ({'removed' : [old_name ], 'added' : ['new name' ]}),
2597
+ ]
2598
+ assert summ_log .arguments == [
2599
+ self .addon ,
2600
+ 'summary' ,
2601
+ json .dumps ({'removed' : [], 'added' : ['summary nouveau' ]}),
2602
+ ]
2542
2603
2543
2604
def test_metadata_change_same_content (self ):
2544
2605
AddonApprovalsCounter .approve_content_for_addon (addon = self .addon )
@@ -2547,7 +2608,7 @@ def test_metadata_change_same_content(self):
2547
2608
).last_content_review
2548
2609
assert old_content_review
2549
2610
self .addon .name = {'en-US' : 'new name' }
2550
- self .addon .summary = {'en-US' : 'new summary' }
2611
+ self .addon .summary = {'en-US' : str ( self . addon . summary ), 'fr' : ' summary nouveau ' }
2551
2612
self .addon .save ()
2552
2613
2553
2614
self ._test_metadata_content_review ()
0 commit comments