Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MP91 committed Sep 7, 2023
1 parent 4988f2b commit a3da95a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dist
build
logs
results
.coverage
2 changes: 1 addition & 1 deletion pantaris_integration/src/gen_desired_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_md5_from_uri(src: str) -> str:
str: The md5-hash of the file.
"""
md5 = hashlib.md5(usedforsecurity=False)
with requests.get(src) as source:
with requests.get(src, timeout=30) as source:
for chunk in source.iter_content(chunk_size=4096):
md5.update(chunk)

Expand Down
13 changes: 0 additions & 13 deletions pantaris_integration/test/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion pantaris_integration/test/integration/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_output():
data = json.load(f)
assert data == {
"name": "SampleApp",
"source": "ghcr.io/eclipse-velocitas/vehicle-app-python-template/sampleapp:v1",
"source": "ghcr.io/eclipse-velocitas/vehicle-app-python-template/sampleapp:v1", # noqa E501
"type": "binary/container",
"requires": [
"vss-source-default-vss:v3.0",
Expand Down
20 changes: 11 additions & 9 deletions pantaris_integration/test/test_gen_desired_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@
#
# SPDX-License-Identifier: Apache-2.0

# flake8: noqa: E402
import os
import sys
from pathlib import Path

from pantaris_integration.src.gen_desired_state import (
get_md5_for_file,
get_md5_from_uri,
is_uri,
)
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
from gen_desired_state import get_md5_for_file, get_md5_from_uri, is_uri


def test_get_md5_for_file():
hash = get_md5_for_file(f"{Path.cwd()}/pantaris_integration/test/__init__.py")
assert hash == "a6527c69275a58815400058232b53e2e"
hash = get_md5_for_file(f"{Path.cwd()}/LICENSE")
# generated with https://emn178.github.io/online-tools/md5_checksum.html
assert hash == "86d3f3a95c324c9479bd8986968f4327"


def test_get_md5_for_uri():
hash = get_md5_from_uri(
"https://raw.githubusercontent.com/eclipse-velocitas/devenv-runtimes/main/pantaris_integration/test/__init__.py"
"https://raw.githubusercontent.com/eclipse-velocitas/devenv-runtimes/main/LICENSE"
)
assert hash == "a6527c69275a58815400058232b53e2e"
# generated with https://emn178.github.io/online-tools/md5_checksum.html
assert hash == "86d3f3a95c324c9479bd8986968f4327"


def test_is_uri__true():
Expand Down

0 comments on commit a3da95a

Please sign in to comment.