Skip to content

Commit

Permalink
DEV-133 update log message
Browse files Browse the repository at this point in the history
  • Loading branch information
philtom-ctds committed Mar 31, 2020
1 parent 273f100 commit ffd50f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions gdc_maf_tool/defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,24 @@ def _realize(self):

response = self._provider()
response.raise_for_status()
self._validate_checksum(response.content)
self._validate_checksum(response)

self._content_position = 0
self._content_length = len(response.content)
self._response = response

def _validate_checksum(self, content):
def _validate_checksum(self, response):
if not self._md5sum:
return

hash_md5 = hashlib.md5() # nosec
hash_md5.update(content)
hash_md5.update(response.content)
md5 = hash_md5.hexdigest()
if self._md5sum != md5:
raise ValueError(f"Failed checksum. Expected {self._md5sum}. Got {md5}.")
raise ValueError(
f"Failed checksum for {response.url}. "
f"Expected {self._md5sum}. Got {md5}."
)

@property
def response(self) -> requests.Response:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ commands =
bandit -r gdc_maf_tool/
bandit -r tests/
flake8
pytest {posargs: -lv tests/ --cov=gdc-maf-tool --cov-report=html}
pytest {posargs: -lv tests/ --cov=gdc_maf_tool --cov-report=html}

0 comments on commit ffd50f7

Please sign in to comment.