Skip to content

Commit

Permalink
Merge pull request #117 from Catrobat/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AntiDog committed Mar 4, 2019
2 parents 19e9709 + 4c8587b commit 598ea95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/scratchtocatrobat/scratch/scratchwebapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/scratchtocatrobat/scratch/test_scratchwebapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 598ea95

Please sign in to comment.