Skip to content

Commit

Permalink
moved test_data/ inside tests/ & updated test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Sim4n6 committed Mar 19, 2022
1 parent 8435fd4 commit 85092a1
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build-n-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This is a basic workflow to Build and Test using Github Actions

name: Build & Test

# Controls when the action will run.
Expand Down Expand Up @@ -119,4 +118,4 @@ jobs:
- name: Run all tests
run: |
cd slack_handler/
pipenv run pytest --verbose tests/
pipenv run pytest --verbose
2 changes: 1 addition & 1 deletion tests/test__csv_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys

CWD = Path().cwd()
TEST_DATA_DIR = CWD.joinpath("test_data")
TEST_DATA_DIR = CWD.joinpath("tests").joinpath("test_data")
SRC_DIR = CWD.joinpath("slack_handler")

# appending a SRC_DIR path for importing utils module
Expand Down
6 changes: 3 additions & 3 deletions tests/test__files_slack_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import re
import shutil


CWD = Path().cwd()
TEST_DATA_DIR = CWD.joinpath("test_data")
TEST_DATA_DIR = CWD.joinpath("tests").joinpath("test_data")
SRC_DIR = CWD.joinpath("slack_handler")

print(TEST_DATA_DIR)

# appending a SRC_DIR path for importing utils module
sys.path.append(str(SRC_DIR))
import utils
Expand Down
20 changes: 4 additions & 16 deletions tests/test__input_files.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from pathlib import Path
import pytest
import subprocess

import sys

# test_data directory
CWD = Path().cwd()
TEST_DATA_DIR = CWD.joinpath("test_data")
SRC_DIR = CWD.joinpath("slack_handler")
TEST_DATA_DIR = CWD.joinpath("tests").joinpath("test_data")

# appending a SRC_DIR path for importing utils module
CWD = Path().cwd()
SRC_DIR = CWD.joinpath("slack_handler")
sys.path.append(str(SRC_DIR))
import utils

Expand Down Expand Up @@ -49,16 +50,3 @@ def test__compare_hashs(disk_image, expected_md5):
with open(test_file, "rb") as f:
md5_hash = utils.MD5_calc(f.read())
assert md5_hash == expected_md5


def test__cli_unfound_disk_img():
"""check std output in case of an unfound disk image"""

proc = subprocess.Popen(
["slack_handler", "--type", "raw", "unfound_disk.img"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdoutput, stderror = proc.communicate()
assert b"unfound_disk.img" in stderror
assert b"not found" in stderror
15 changes: 14 additions & 1 deletion tests/test__module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess

CWD = Path().cwd()
TEST_DATA_DIR = CWD.joinpath("test_data")
TEST_DATA_DIR = CWD.joinpath("tests").joinpath("test_data")
SRC_DIR = CWD.joinpath("slack_handler")

def test__module():
Expand All @@ -21,3 +21,16 @@ def test__module():
stdoutput, stderror = proc.communicate()

assert b"v" in stdoutput


def test__cli_unfound_disk_img():
"""check std output in case of an unfound disk image"""

proc = subprocess.Popen(
["slack_handler", "--type", "raw", "unfound_disk.img"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdoutput, stderror = proc.communicate()
assert b"unfound_disk.img" in stderror
assert b"not found" in stderror
2 changes: 1 addition & 1 deletion tests/test__printed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess

CWD = Path().cwd()
TEST_DATA_DIR = CWD.joinpath("test_data")
TEST_DATA_DIR = CWD.joinpath("tests").joinpath("test_data")
SRC_DIR = CWD.joinpath("slack_handler")


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 85092a1

Please sign in to comment.