36
36
}
37
37
38
38
TEST_PROJECT_ID_TO_IMAGE_URL_MAP = {
39
- "10205819" : "https://uploads .scratch.mit.edu/projects/thumbnails/10205819 .png" ,
40
- "10132588" : "https://uploads .scratch.mit.edu/projects/thumbnails/10132588 .png" ,
41
- "2365565" : "https://uploads .scratch.mit.edu/projects/thumbnails/2365565 .png" ,
42
- "117300839" : "https://uploads .scratch.mit.edu/projects/thumbnails/117300839 .png"
39
+ "10205819" : "https://cdn2 .scratch.mit.edu/get_image/project/10205819_480x360 .png" ,
40
+ "10132588" : "https://cdn2 .scratch.mit.edu/get_image/project/10132588_480x360 .png" ,
41
+ "2365565" : "https://cdn2 .scratch.mit.edu/get_image/project/2365565_480x360 .png" ,
42
+ "117300839" : "https://cdn2 .scratch.mit.edu/get_image/project/117300839_480x360 .png"
43
43
}
44
44
45
45
TEST_PROJECT_ID_TO_OWNER_MAP = {
245
245
}]
246
246
}
247
247
248
- TEST_PROJECT_ID_TO_TAGS_MAP = {
249
- "10205819" : ['animations' , 'castle' ],
250
- "10132588" : ['music' , 'simulations' , 'animations' ],
251
- "2365565" : [],
252
- "117300839" : []
253
- }
254
-
255
248
TEST_PROJECT_ID_TO_INSTRUCTIONS_MAP = {
256
249
"10205819" : "Click the flag to run the stack. Click the space bar to change it up!" ,
257
250
"10132588" : "D,4,8 for the animals to move.C,A for background. " ,
@@ -297,40 +290,6 @@ def test_can_request_project_code_for_id(self):
297
290
raw_project = scratch .RawProject .from_project_code_content (project_code_content )
298
291
assert raw_project is not None
299
292
300
- def test_can_request_project_title_for_id (self ):
301
- for (project_id , expected_project_title ) in TEST_PROJECT_ID_TO_TITLE_MAP .iteritems ():
302
- extracted_project_title = scratchwebapi .getMetaDataEntry (project_id , 'title' )
303
- assert extracted_project_title is not None
304
- assert extracted_project_title == expected_project_title , \
305
- "'{}' is not equal to '{}'" .format (extracted_project_title , expected_project_title )
306
-
307
- def test_can_request_project_title_and_image_for_id (self ):
308
- extracted_project_title , image = scratchwebapi .getMetaDataEntry (10205819 , "title" , "image" )
309
- assert extracted_project_title == "Dancin' in the Castle"
310
- assert image == "https://cdn2.scratch.mit.edu/get_image/project/10205819_480x360.png"
311
-
312
- def test_can_request_project_owner_for_id (self ):
313
- for (project_id , expected_project_owner ) in TEST_PROJECT_ID_TO_OWNER_MAP .iteritems ():
314
- extracted_project_owner = scratchwebapi .getMetaDataEntry (project_id , 'username' )
315
-
316
- assert extracted_project_owner is not None
317
- assert extracted_project_owner == expected_project_owner , \
318
- "'{}' is not equal to '{}'" .format (extracted_project_owner , expected_project_owner )
319
-
320
- def test_can_request_project_instructions_for_id (self ):
321
- for (project_id , expected_project_instructions ) in TEST_PROJECT_ID_TO_INSTRUCTIONS_MAP .iteritems ():
322
- extracted_project_instructions = scratchwebapi .getMetaDataEntry (project_id , 'instructions' )
323
- assert extracted_project_instructions == expected_project_instructions , \
324
- "'{}' is not equal to '{}'" .format (extracted_project_instructions , expected_project_instructions )
325
-
326
- def test_can_request_project_notes_and_credits_for_id (self ):
327
- for (project_id , expected_project_notes_and_credits ) in TEST_PROJECT_ID_TO_NOTES_AND_CREDITS_MAP .iteritems ():
328
- extracted_project_notes_and_credits = scratchwebapi .getMetaDataEntry (project_id , 'description' )
329
- assert extracted_project_notes_and_credits is not None
330
- assert extracted_project_notes_and_credits == expected_project_notes_and_credits , \
331
- "'{}' is not equal to '{}'" .format (extracted_project_notes_and_credits ,
332
- expected_project_notes_and_credits )
333
-
334
293
def test_can_request_remixes_for_id (self ):
335
294
for (project_id , expected_project_remixes ) in TEST_PROJECT_ID_TO_REMIXES_MAP .iteritems ():
336
295
extracted_project_remixes = scratchwebapi .request_project_remixes_for (project_id )
@@ -345,40 +304,28 @@ def test_extract_project_details(self):
345
304
assert details .as_dict ()["modified_date" ] != None
346
305
assert details .as_dict ()["shared_date" ] != None
347
306
348
- # def test_can_request_project_info_for_id(self):
349
- # for (project_id, expected_project_title) in TEST_PROJECT_ID_TO_TITLE_MAP.iteritems():
350
- # extracted_project_info = scratchwebapi.request_project_details_for(project_id)
351
- # assert extracted_project_info is not None
352
- # assert isinstance(extracted_project_info, scratchwebapi.ScratchProjectInfo)
353
- # assert extracted_project_info.title is not None
354
- # assert extracted_project_info.title == expected_project_title, \
355
- # "'{}' is not equal to '{}'".format(extracted_project_info.title, expected_project_title)
356
- # assert extracted_project_info.owner is not None
357
- # assert extracted_project_info.owner == TEST_PROJECT_ID_TO_OWNER_MAP[project_id], \
358
- # "'{}' is not equal to '{}'".format(extracted_project_info.owner, TEST_PROJECT_ID_TO_OWNER_MAP[project_id])
359
- # assert extracted_project_info.image_url is not None
360
- # assert extracted_project_info.image_url == TEST_PROJECT_ID_TO_IMAGE_URL_MAP[project_id], \
361
- # "'{}' is not equal to '{}'".format(extracted_project_info.image_url, TEST_PROJECT_ID_TO_IMAGE_URL_MAP[project_id])
362
- # assert extracted_project_info.instructions == TEST_PROJECT_ID_TO_INSTRUCTIONS_MAP[project_id], \
363
- # "'{}' is not equal to '{}'".format(extracted_project_info.instructions, TEST_PROJECT_ID_TO_INSTRUCTIONS_MAP[project_id])
364
- # assert extracted_project_info.notes_and_credits == TEST_PROJECT_ID_TO_NOTES_AND_CREDITS_MAP[project_id], \
365
- # "'{}' is not equal to '{}'".format(extracted_project_info.notes_and_credits, TEST_PROJECT_ID_TO_NOTES_AND_CREDITS_MAP[project_id])
366
- # assert extracted_project_info.tags is not None
367
- # assert extracted_project_info.tags == TEST_PROJECT_ID_TO_TAGS_MAP[project_id], \
368
- # "'{}' is not equal to '{}'".format(extracted_project_info.tags, TEST_PROJECT_ID_TO_TAGS_MAP[project_id])
369
- # assert extracted_project_info.views is not None
370
- # assert isinstance(extracted_project_info.views, int)
371
- # assert extracted_project_info.views > 0
372
- # assert extracted_project_info.favorites is not None
373
- # assert extracted_project_info.favorites >= 0
374
- # assert isinstance(extracted_project_info.favorites, int)
375
- # assert extracted_project_info.loves is not None
376
- # assert extracted_project_info.loves >= 0
377
- # assert isinstance(extracted_project_info.loves, int)
378
- # assert extracted_project_info.modified_date is not None
379
- # assert isinstance(extracted_project_info.modified_date, datetime)
380
- # assert extracted_project_info.shared_date is not None
381
- # assert isinstance(extracted_project_info.shared_date, datetime)
307
+ def test_can_request_project_info_for_id (self ):
308
+ for (project_id , expected_project_title ) in TEST_PROJECT_ID_TO_TITLE_MAP .iteritems ():
309
+ title , owner , image_url , instructions , notes_and_credits , stats , history \
310
+ = scratchwebapi .getMetaDataEntry (project_id , 'title' , 'username' , 'image' , 'instructions' , 'description' , 'stats' , 'history' )
311
+ assert title == expected_project_title , \
312
+ "'{}' is not equal to '{}'" .format (title , expected_project_title )
313
+ assert owner == TEST_PROJECT_ID_TO_OWNER_MAP [project_id ], \
314
+ "'{}' is not equal to '{}'" .format (owner , TEST_PROJECT_ID_TO_OWNER_MAP [project_id ])
315
+ assert image_url == TEST_PROJECT_ID_TO_IMAGE_URL_MAP [project_id ], \
316
+ "'{}' is not equal to '{}'" .format (image_url , TEST_PROJECT_ID_TO_IMAGE_URL_MAP [project_id ])
317
+ assert instructions == TEST_PROJECT_ID_TO_INSTRUCTIONS_MAP [project_id ], \
318
+ "'{}' is not equal to '{}'" .format (instructions , TEST_PROJECT_ID_TO_INSTRUCTIONS_MAP [project_id ])
319
+ assert notes_and_credits == TEST_PROJECT_ID_TO_NOTES_AND_CREDITS_MAP [project_id ], \
320
+ "'{}' is not equal to '{}'" .format (notes_and_credits , TEST_PROJECT_ID_TO_NOTES_AND_CREDITS_MAP [project_id ])
321
+ assert isinstance (stats ['views' ], int )
322
+ assert stats ['views' ] > 0
323
+ assert isinstance (stats ['favorites' ], int )
324
+ assert stats ['favorites' ] >= 0
325
+ assert isinstance (stats ['loves' ], int )
326
+ assert stats ['loves' ] >= 0
327
+ assert isinstance (scratchwebapi .convertHistoryDatesToDatetime (history ['modified' ]), datetime )
328
+ assert isinstance (scratchwebapi .convertHistoryDatesToDatetime (history ['shared' ]), datetime )
382
329
383
330
def test_can_detect_correct_availability_state_of_project (self ):
384
331
project_availability_map = {
0 commit comments