-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from kuefmz/master
Fix download endpoint and add testcases
- Loading branch information
Showing
5 changed files
with
148 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Pylint | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- uses: Gr1N/setup-poetry@v8 #install poetry | ||
- name: Install parts of toolchain | ||
run: | | ||
python -m pip install --upgrade pip | ||
- name: Install requirements with poetry | ||
run: poetry install | ||
- name: Test with pytest | ||
run: | | ||
poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import unittest | ||
import subprocess | ||
import time | ||
import requests | ||
import os | ||
import hashlib | ||
|
||
|
||
class TestServerResponses(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
os.chdir("archivo") | ||
# Start the server | ||
cls.server_process = subprocess.Popen(["poetry", "run", "python", "archivo.py"]) | ||
# Give the server some time to start up | ||
time.sleep(5) | ||
|
||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
# Shut down the server | ||
cls.server_process.terminate() | ||
cls.server_process.wait() | ||
|
||
|
||
def test_response_second_url(self): | ||
url = "http://localhost:5000/download?o=http%3A//comicmeta.org/cbo/&f=owl&v=2023.03.18-185709&vM=closest" | ||
response = requests.get(url) | ||
|
||
# Calculate the MD5 checksum of the content | ||
md5_hash = hashlib.md5(response.content).hexdigest() | ||
expected_md5 = "4176659915aaacc0b7960dd7428d5439" | ||
self.assertEqual(md5_hash, expected_md5) | ||
|
||
|
||
def test_response_first_url(self): | ||
url = "http://localhost:5000/download?o=http%3A//comicmeta.org/cbo/&f=owl&v=2024.05.29-031359&vM=closest" | ||
response = requests.get(url) | ||
|
||
# Calculate the MD5 checksum of the content | ||
md5_hash = hashlib.md5(response.content).hexdigest() | ||
expected_md5 = "4196656da08e5b248dc1a9eaca3c888c" | ||
self.assertEqual(md5_hash, expected_md5) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |