Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Initial Test Cases and Increase Coverage #32

Closed
wants to merge 79 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
4456609
Feat(main): Add the rebekah test - print statement in main
PCain02 Sep 5, 2024
d80fd42
test files made
Coltin2121 Sep 12, 2024
ac57869
feat: Added a testing coverage to the pyproject.toml
rebekahrudd Sep 12, 2024
6537d30
Merge branch 'GatorEducator:main' into main
PCain02 Sep 15, 2024
6ece3f7
Merge branch 'GatorEducator:main' into PyPI-automation
PCain02 Sep 15, 2024
6be9815
feat: Create publish.yml and add content
PCain02 Sep 15, 2024
2fd4181
feat: optimize publish.yml with caching, version verification, error …
PCain02 Sep 15, 2024
f3f5595
feat: Create test-publish.yml to test automatic releases
PCain02 Sep 17, 2024
81b417c
Chore: Bump version to 0.3.2
PCain02 Sep 18, 2024
dfd0752
feat: Update publish.yml to realease on tag
PCain02 Sep 18, 2024
d73bdf8
Feat: Update test-publish.yml to release on t
PCain02 Sep 18, 2024
a925d66
Merge branch 'PyPI-automation' of https://github.com/PCain02/execexam…
PCain02 Sep 18, 2024
fc666e0
Chore: Bump version to 0.3.4 test
PCain02 Sep 19, 2024
8ac723f
Chore: Bump version to 0.3.5 test
PCain02 Sep 19, 2024
b2299f4
Chore: Bump version to 0.3.7 test
PCain02 Sep 19, 2024
d579734
Chore: Bump version to 0.3.8 test
PCain02 Sep 19, 2024
94c0464
Chore: Bump version to 0.3.8 test
PCain02 Sep 19, 2024
59e3c0c
Chore: Bump version to 0.3.9 test
PCain02 Sep 19, 2024
2370b03
Chore: Bump version to 0.3.10 test and fix version tag bug
PCain02 Sep 19, 2024
ce49937
Chore: Bump version to 0.3.10 test and fix version tag bug
PCain02 Sep 19, 2024
aaf3422
fix: delete problematic files and test tag 0.3.11
PCain02 Sep 19, 2024
f4f79c7
Chore: Bump version to 0.3.11 test and fix version tag bug
PCain02 Sep 19, 2024
e3e8aba
Chore: Bump version to 0.3.12 test and fix version tag bug
PCain02 Sep 19, 2024
124ad74
Chore: Bump version to 0.3.13 test and fix version tag bug
PCain02 Sep 19, 2024
8342a74
Chore: Bump version to 0.3.14 test and fix version tag bug
PCain02 Sep 19, 2024
a4d5063
Chore: Bump version to 0.3.15 test and fix version tag bug
PCain02 Sep 19, 2024
646582d
Chore: Bump version to 0.3.16 test and fix version tag bug
PCain02 Sep 19, 2024
f1bd6d9
Chore: Bump version to 0.3.17 test and fix version tag bug
PCain02 Sep 19, 2024
5a600c1
Chore: Bump version to 0.3.18 test and fix version tag bug
PCain02 Sep 19, 2024
382d0c8
Chore: Bump version to 0.3.19 test and fix version tag bug
PCain02 Sep 19, 2024
29e36d1
Chore: Bump version to 0.3.2 test and fix version tag bug
PCain02 Sep 19, 2024
fe76001
Chore: Bump version to 0.3.21 test and fix version tag bug
PCain02 Sep 19, 2024
2bee9fc
Chore: Bump version to 0.3.22 test and fix version tag bug
PCain02 Sep 19, 2024
add533a
Chore: Bump version to 0.3.23 test
PCain02 Sep 19, 2024
fb91b3b
Chore: Bump version to 0.3.24 test
PCain02 Sep 19, 2024
16fdb33
Chore: Bump version to 0.3.25 test simplify test-publish
PCain02 Sep 19, 2024
5283552
Chore: Bump version to 0.3.26 test simplify test-publish
PCain02 Sep 19, 2024
d08d75e
Chore: Bump version to 0.3.27 test simplify test-publish
PCain02 Sep 19, 2024
abc085b
Chore: Bump version to 0.3.28 test simplify test-publish
PCain02 Sep 19, 2024
5ba6235
feat: simplify publish.yml to work like test-publish.yml
PCain02 Sep 19, 2024
63da4c5
feat add testing for enumeration
hannahb09 Sep 19, 2024
fa6bcae
chore: bump version to 0.3.29 test
PCain02 Sep 19, 2024
ba30bec
chore: bump version to 0.3.33 test
PCain02 Sep 20, 2024
ae45aa2
add(tests): added test suites to test pytest_plugin.py.
Chezka109 Sep 20, 2024
de122ff
fix: Delete tests/__init__.py empty test file
PCain02 Sep 20, 2024
2093d05
fix: delete empty test case files and Rebekah Test
PCain02 Sep 20, 2024
b876aef
Merge branch 'main' of github.com:PCain02/execexam into testing
Chezka109 Sep 20, 2024
34dc9c4
Merge branch 'testing' of github.com:PCain02/execexam into testing
Chezka109 Sep 20, 2024
459ca6d
fix: test cases in test_pytest_plugin.py
rebekahrudd Sep 20, 2024
52356a1
fix: made edits in assert lines test_pytest_plugin.py
rebekahrudd Sep 20, 2024
5799e5a
Fix: Update pyproject.toml version number and return it to the original
PCain02 Sep 20, 2024
4fcff73
Merge branch 'main' of github.com:PCain02/execexam into testing
Chezka109 Sep 20, 2024
8759c61
Merge branch 'testing' of github.com:PCain02/execexam into testing
Chezka109 Sep 20, 2024
cfa71c3
feat(README): badges for coverage and maintenance added, as well as l…
Chezka109 Sep 20, 2024
2cde7a2
Merge pull request #3 from PCain02/PyPI-automation
PCain02 Sep 22, 2024
859fbe2
Feat: add back init.py to tests
PCain02 Sep 22, 2024
ab79380
feat: add back __init__.py to tests
PCain02 Sep 22, 2024
38c8872
Merge branch 'main' of https://github.com/PCain02/execexam
PCain02 Sep 22, 2024
94043b0
Merge branch 'main' of https://github.com/PCain02/execexam
PCain02 Sep 22, 2024
723eeae
Fix: Update __init__.py to be empty file
PCain02 Sep 22, 2024
4e54de8
moving badges feature to infrastructure branch
Chezka109 Sep 23, 2024
6b94d08
test: added a pytest command to build.yml
rebekahrudd Sep 23, 2024
c6ce071
Merge branch 'main' of github.com:PCain02/execexam into testing
rebekahrudd Sep 24, 2024
b84bef0
feat: add testing coverage for main.py
hannahb09 Sep 26, 2024
0b8a4cb
feature: added testing for main.py
hannahb09 Sep 26, 2024
3ea8d07
feat: testing added to test_dipslay.py
Coltin2121 Sep 26, 2024
bbe302b
chore: fix testing bug
hannahb09 Sep 26, 2024
d8f1baf
feat: started working to fix all text cases so they run
dyga01 Sep 28, 2024
47cf433
fix(tests): worked to fix all tests so that they can pass
dyga01 Sep 30, 2024
dba593b
test: testing added in test_display.py for display_advice and get_dis…
Coltin2121 Oct 2, 2024
cba6073
chore: added a file for test_debug.py
hannahb09 Oct 2, 2024
bdc6074
fix(cli.py): worked to delete the cli.py file
dyga01 Oct 2, 2024
6172926
feat(test_debug.py): worked to add tests for debug file
dyga01 Oct 2, 2024
90f14e8
feat(test_pytest_plugin.py): worked to add tests for the pytest plugin
dyga01 Oct 2, 2024
f233583
feat: added docstrings to all testing functions
dyga01 Oct 2, 2024
640736a
fix: formatted all the code with ruff
dyga01 Oct 2, 2024
0830044
fix(poetry.lock): updated the poetry.lock file
dyga01 Oct 2, 2024
be1cc56
fix(build.yml): have the build run the fuzzy tests
dyga01 Oct 2, 2024
c620d83
fix(build.yml): added the correct commands for running tests
dyga01 Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ jobs:
# do not run the Hypothesis-based fuzz tests
# because they sometimes take longer to run
# on Windows and MacOS and this creates errors
poetry run task test-not-fuzz
poetry run task test
poetry run task coverage
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish

on:
push:
tags:
- 'v*' # Triggers on tags starting with 'v'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11' # Use the Python version compatible with your project

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry install

- name: Configure Poetry for PyPI
run: |
poetry config repositories.pypi https://upload.pypi.org/legacy/
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}

- name: Publish package to PyPI
run: |
poetry publish --repository pypi --build

- name: Check for Successful Publication
run: |
version=$(poetry version --short)
echo "Checking if package execexam version $version is available on PyPI..."
response=$(curl -s "https://pypi.org/pypi/execexam/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package execexam version $version is successfully published on PyPI."
else
echo "Package execexam version $version was not found on PyPI."
exit 1
fi

48 changes: 48 additions & 0 deletions .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test Publish

on:
push:
tags:
- 't*' # Triggers on tags starting with 't'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '^3.11' # Use the Python version compatible with your project

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry install

- name: Configure Poetry for TestPyPI
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}

- name: Publish package to TestPyPI
run: |
poetry publish --repository testpypi --build

- name: Check for Successful Publication
run: |
version=$(poetry version --short)
echo "Checking if package execexam version $version is available on TestPyPI..."
response=$(curl -s "https://test.pypi.org/pypi/execexam/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package execexam version $version is successfully published on TestPyPI."
else
echo "Package execexam version $version was not found on TestPyPI."
exit 1
fi
1,252 changes: 638 additions & 614 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ filterwarnings = [
"error",
]
enable_assertion_pass_hook = true
markers = [
"order(number): marks test to run in a specific order"
]

[tool.ruff]
line-length = 79
Expand Down Expand Up @@ -62,7 +65,7 @@ line_length = 88
project = "execexam"
tests = "tests"
check-command = { var = "ruff check {project} {tests}", recursive = true }
coverage-test-command = "pytest -s --cov-context=test --cov-fail-under=90 --cov-report term-missing --cov-report json --cov --cov-branch"
coverage-test-command = "pytest -s --cov-context=test --cov-fail-under=50 --cov-report term-missing --cov-report json --cov --cov-branch"
coverage-test-command-silent = "pytest -x --show-capture=no --cov-report term-missing --cov-report json --cov --cov-branch"
developer-test-command = "pytest -x -s"
developer-test-silent-command = "pytest -x --show-capture=no"
Expand All @@ -76,6 +79,8 @@ mypy-command = {var = "mypy {project}", recursive = true}
all = "task lint && task test"
lint = "task format && task check && task mypy && task symbex"
check = { cmd = "{check-command}", help = "Run the ruff linting checks", use_vars = true }
coverage = { cmd = "{coverage-test-command}", help = "Run test coverage monitoring", use_vars = true }
coverage-silent = { cmd = "{coverage-test-command-silent}", help = "Run test coverage monitoring", use_vars = true }
format = { cmd = "{format-command}", help = "Run the ruff formatter on source code", use_vars = true }
format-fix = { cmd = "{fixformat-command}", help = "Run the ruff formatter to fix source code", use_vars = true }
mypy = { cmd = "{mypy-command}", help = "Run the mypy type checker for potential type errors", use_vars = true }
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions tests/test_advise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Testing for the advise module"""
3 changes: 2 additions & 1 deletion tests/test_convert.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Test cases for the convert module."""
"""Test cases for the convert.py file."""

from pathlib import Path

from execexam.convert import path_to_string


def test_path_to_string():
"""Test the path_to_string function from the convert module."""
# path that has more than 4 parts
path = Path("/home/user/documents/work/project/file.txt")
result = path_to_string(path)
Expand Down
77 changes: 77 additions & 0 deletions tests/test_debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""Test cases for the debug.py file."""

import pytest

from execexam.debug import (
Debug,
debug,
get_debugging_messages,
has_debugging_messages,
messages,
)


@pytest.fixture(autouse=True)
def clear_messages():
"""Fixture to clear messages before each test."""
messages.clear()


def test_enum_values():
"""Test the values of the Debug enum."""
assert (
Debug.get_advice_with_llm.value
== "[green]\u2714 Correctly requested and received advice from an LLM."
)
assert (
Debug.parameter_check_passed.value
== "[green]\u2714 Validity check passed for command-line arguments."
)
assert (
Debug.pytest_passed_with_marks.value
== "[green]\u2714 Correctly ran pytest when using marks."
)
assert (
Debug.pytest_passed_without_marks.value
== "[green]\u2714 Correctly ran pytest when not using marks."
)


def test_messages_list_initially_empty():
"""Test that the messages list is initially empty."""
assert messages == []


def test_add_message():
"""Test adding a message to the messages list."""
messages.append(Debug.get_advice_with_llm.value)
assert Debug.get_advice_with_llm.value in messages


def test_clear_messages():
"""Test clearing the messages list."""
messages.append(Debug.get_advice_with_llm.value)
messages.clear()
assert messages == []


def test_debug_function():
"""Test the debug function."""
debug(True, "Test message")
assert "Test message" in messages
debug(False, "Another message")
assert "Another message" not in messages


def test_has_debugging_messages():
"""Test the has_debugging_messages function."""
assert not has_debugging_messages()
messages.append("Test message")
assert has_debugging_messages()


def test_get_debugging_messages():
"""Test the get_debugging_messages function."""
assert get_debugging_messages() == ""
messages.append("Test message")
assert get_debugging_messages() == "\nTest message\n"
124 changes: 124 additions & 0 deletions tests/test_display.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
"""Test cases for the display.py file."""

from typing import Any, Dict


def make_colon_separated_string(arguments: Dict[str, Any]) -> str:
"""Make a colon separated string from a dictionary."""
return "\n" + "\n".join(
f"- {key}: {value}" for key, value in arguments.items()
)


def test_make_colon_separated_string():
"""Function tests colon separated string outputs with different dictionaries."""
# Basic dictionary test
input_dictionary = {"key1": "value1", "key2": "value2"}
expected_output = "\n- key1: value1\n- key2: value2"
assert make_colon_separated_string(input_dictionary) == expected_output
# Test with an empty dictionary
input_dictionary = {}
expected_output = "\n"
assert make_colon_separated_string(input_dictionary) == expected_output
# Test with numbers
input_dictionary = {"key1": 123, "key2": 25.5}
expected_output = "\n- key1: 123\n- key2: 25.5"
assert make_colon_separated_string(input_dictionary) == expected_output
# Test with mixed types
input_dictionary = {"key1": "value1", "key2": None, "key3": [1, 2, 3]}
expected_output = "\n- key1: value1\n- key2: None\n- key3: [1, 2, 3]"
assert make_colon_separated_string(input_dictionary) == expected_output
# Test special characters
input_dictionary = {"key1": "!@#$%", "key2": "value2/*&"}
expected_output = "\n- key1: !@#$%\n- key2: value2/*&"
assert make_colon_separated_string(input_dictionary) == expected_output


# Function to test
def get_display_return_code(return_code: int, fancy: bool) -> str:
"""Determine the return code from running the specified checks(s)."""
message = "\n"
if return_code == 0:
message += "[green]\u2714 All checks passed."
else:
message += "[red]\u2718 One or more checks failed."
if fancy:
message += "\n"
return message


# Tests
def test_get_display_return_code():
"""Test the get_display_return_code function with various inputs."""
# Test case where checks pass (return_code is 0)
# fancy: bool is False
assert (
get_display_return_code(0, False)
== "\n[green]\u2714 All checks passed."
)
# Test case where checks pass (return_code is 0)
# fancy: bool is True
assert (
get_display_return_code(0, True)
== "\n[green]\u2714 All checks passed.\n"
)
# Test case where checks fail (return_code is 1)
# fancy: bool is False
assert (
get_display_return_code(1, False)
== "\n[red]\u2718 One or more checks failed."
)
# Test case where checks fail (return_code is 1)
# fancy: bool is True
assert (
get_display_return_code(1, True)
== "\n[red]\u2718 One or more checks failed.\n"
)
# Test case for another 2 return code
# fancy: bool is False
assert (
get_display_return_code(2, False)
== "\n[red]\u2718 One or more checks failed."
)


# Function to test
def display_advice(return_code: int) -> str:
"""Determine the return code from running the specified checks(s)."""
message = "\n"
if return_code == 0:
message += "[green]\u2714 Advise requested, but none is needed!"
else:
message += "[red]\u2718 Advise requested, and will be provided!"
message += "\n"
return message


# Tests
def test_display_advice():
"""Test the display_advice function with various return codes."""
# Test case where no advice is needed (return_code is 0)
assert (
display_advice(0)
== "\n[green]\u2714 Advise requested, but none is needed!\n"
)
# Test case where advice is needed (return_code is non-zero)
assert (
display_advice(1)
== "\n[red]\u2718 Advise requested, and will be provided!\n"
)
# Test case for another non-zero return code
assert (
display_advice(2)
== "\n[red]\u2718 Advise requested, and will be provided!\n"
)
# Test case for negative return code
assert (
display_advice(-1)
== "\n[red]\u2718 Advise requested, and will be provided!\n"
)
# Test case for a large return code
assert (
display_advice(999)
== "\n[red]\u2718 Advise requested, and will be provided!\n"
)
Loading
Loading