diff --git a/src/scratchtocatrobat/scratch/scratchwebapi.py b/src/scratchtocatrobat/scratch/scratchwebapi.py index d7546c77..96d13af6 100644 --- a/src/scratchtocatrobat/scratch/scratchwebapi.py +++ b/src/scratchtocatrobat/scratch/scratchwebapi.py @@ -275,18 +275,18 @@ def extract_project_details(project_id, escape_quotes=True): extracted_text = getMetaDataEntry(project_id , "history") extracted_text = extracted_text["modified"] if extracted_text is None: return None - modified_date_str = unicode(extracted_text).replace("Modified:", "").strip() + modified_date_str = unicode(extracted_text).replace("Modified:", "").replace("Z","000").strip() try: - modified_date = datetime.strptime(modified_date_str, '%d %b %Y') + modified_date = datetime.strptime(modified_date_str, "%Y-%m-%dT%H:%M:%S.%f") except: modified_date = None extracted_text = getMetaDataEntry(project_id , "history") extracted_text = extracted_text["shared"] if extracted_text is None: return None - shared_date_str = unicode(extracted_text).replace("Shared:", "").strip() + shared_date_str = unicode(extracted_text).replace("Shared:", "").replace("Z","000").strip() try: - shared_date = datetime.strptime(shared_date_str, '%d %b %Y') + shared_date = datetime.strptime(shared_date_str, "%Y-%m-%dT%H:%M:%S.%f") except: shared_date = None diff --git a/src/scratchtocatrobat/scratch/test_scratchwebapi.py b/src/scratchtocatrobat/scratch/test_scratchwebapi.py index 3903e5d5..47529f8e 100644 --- a/src/scratchtocatrobat/scratch/test_scratchwebapi.py +++ b/src/scratchtocatrobat/scratch/test_scratchwebapi.py @@ -340,8 +340,12 @@ def test_can_request_remixes_for_id(self): assert extracted_project_remixes == expected_project_remixes, \ "'{}' is not equal to '{}'".format(extracted_project_remixes, expected_project_remixes) + def test_extract_project_details(self): + details = scratchwebapi.extract_project_details(10205819, escape_quotes=True) + assert details.as_dict()["modified_date"] != None + assert details.as_dict()["shared_date"] != None - # def test_can_request_project_info_for_id(self): +# def test_can_request_project_info_for_id(self): # for (project_id, expected_project_title) in TEST_PROJECT_ID_TO_TITLE_MAP.iteritems(): # extracted_project_info = scratchwebapi.request_project_details_for(project_id) # assert extracted_project_info is not None