@@ -84,6 +84,12 @@ def test_main_ok_exist_article_id(self):
8484 'pathParameters' : {
8585 'article_id' : self .article_fraud_user_table_items [0 ]['article_id' ]
8686 },
87+ 'body' : json .dumps ({
88+ 'reason' : 'plagiarism' ,
89+ 'plagiarism_url' : 'http://test.com' ,
90+ 'plagiarism_description' : 'plagiarism description' ,
91+ 'illegal_content' : 'illegal content'
92+ }),
8793 'requestContext' : {
8894 'authorizer' : {
8995 'claims' : {
@@ -103,12 +109,21 @@ def test_main_ok_exist_article_id(self):
103109
104110 target_article_id = params ['pathParameters' ]['article_id' ]
105111 target_user_id = params ['requestContext' ]['authorizer' ]['claims' ]['cognito:username' ]
112+ body = json .loads (params ['body' ])
113+ target_reason = body ['reason' ]
114+ target_plagiarism_url = body ['plagiarism_url' ]
115+ target_plagiarism_description = body ['plagiarism_description' ]
116+ target_illegal_content = body ['illegal_content' ]
106117
107118 article_fraud_user = self .get_article_fraud_user (target_article_id , target_user_id )
108119
109120 expected_items = {
110121 'article_id' : target_article_id ,
111122 'user_id' : target_user_id ,
123+ 'reason' : target_reason ,
124+ 'plagiarism_url' : target_plagiarism_url ,
125+ 'plagiarism_description' : target_plagiarism_description ,
126+ 'illegal_content' : target_illegal_content ,
112127 'created_at' : 1520150272000003
113128 }
114129
@@ -185,38 +200,63 @@ def test_validation_article_id_min(self):
185200
186201 def test_validation_invalid_reason (self ):
187202 params = {
188- 'pathParameters' : {
189- 'article_id' : self .article_fraud_user_table_items [1 ]['article_id' ]
190- },
191- 'body' : json .dumps ({'reason' : 'abcde' }),
192- 'requestContext' : {
193- 'authorizer' : {
194- 'claims' : {
195- 'cognito:username' : 'test03'
196- }
197- }
198- }
203+ 'body' : json .dumps ({'reason' : 'abcde' })
199204 }
200205 self .assert_bad_request (params )
201206
202207 def test_validation_required_plagiarism_url_when_reason_is_plagiarism (self ):
203208 params = {
204- 'pathParameters' : {
205- 'article_id' : self .article_fraud_user_table_items [2 ]['article_id' ]
206- },
207209 'body' : json .dumps (
208210 {
209211 'reason' : 'plagiarism' ,
210212 'plagiarism_url' : '' ,
211213 }
212- ),
213- 'requestContext' : {
214- 'authorizer' : {
215- 'claims' : {
216- 'cognito:username' : 'test03'
217- }
214+ )
215+ }
216+ self .assert_bad_request (params )
217+
218+ def test_validation_required_plagiarism_description_when_reason_is_plagiarism (self ):
219+ params = {
220+ 'body' : json .dumps (
221+ {
222+ 'reason' : 'plagiarism' ,
223+ 'plagiarism_url' : 'http://test.com' ,
224+ 'plagiarism_description' : '' ,
218225 }
219- }
226+ )
227+ }
228+ self .assert_bad_request (params )
229+
230+ def test_validation_invalid_plagiarism_url_when_reason_is_plagiarism (self ):
231+ params = {
232+ 'body' : json .dumps (
233+ {
234+ 'reason' : 'plagiarism' ,
235+ 'plagiarism_url' : 'aaa'
236+ }
237+ )
238+ }
239+ self .assert_bad_request (params )
240+
241+ def test_validation_required_illegal_content_when_reason_is_illegal (self ):
242+ params = {
243+ 'body' : json .dumps (
244+ {
245+ 'reason' : 'illegal' ,
246+ 'illegal_content' : '' ,
247+ }
248+ )
249+ }
250+ self .assert_bad_request (params )
251+
252+ def test_validation_required_illegal_content_when_reason_is_other (self ):
253+ params = {
254+ 'body' : json .dumps (
255+ {
256+ 'reason' : 'other' ,
257+ 'illegal_content' : '' ,
258+ }
259+ )
220260 }
221261 self .assert_bad_request (params )
222262
0 commit comments