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

more tests! #138

Merged
merged 3 commits into from
Aug 21, 2024
Merged

more tests! #138

merged 3 commits into from
Aug 21, 2024

Conversation

ryansurf
Copy link
Owner

@ryansurf ryansurf commented Aug 21, 2024

General:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code:

  1. Does your submission pass tests?
  2. Have you run the linter/formatter on your code locally before submission?
  3. Have you updated the documentation/README to reflect your changes, as applicable?
  4. Have you added an explanation of what your changes do?
  5. Have you written new tests for your changes, as applicable?

More tests have been added! The art is now tested, along with the simple gpt.

Summary by Sourcery

Add new tests for the art and gpt modules, refactor import statements in test_helper.py, and enhance test coverage for the extract_decimal function.

New Features:

  • Add new tests for the art module to ensure the print_wave function outputs correctly.

Enhancements:

  • Refactor import statements in test_helper.py to improve module organization.

Tests:

  • Introduce tests for the simple_gpt function in test_gpt.py to verify its output.
  • Add tests in test_helper.py to validate the behavior of the extract_decimal function with invalid and default inputs.

Copy link
Contributor

sourcery-ai bot commented Aug 21, 2024

Reviewer's Guide by Sourcery

This pull request adds more tests to the project, focusing on improving test coverage for the art functionality, simple GPT integration, and some refactoring in existing tests. The changes include new test files, modifications to existing test files, and updates to import statements.

File-Level Changes

Files Changes
tests/test_helper.py Refactored import statements and function calls in test_helper.py to use the 'helper' module instead of directly importing 'extract_decimal'
tests/test_helper.py Added a new test function 'test_print_gpt()' to verify the functionality of the simple_gpt() function
tests/test_gpt.py Created a new test file 'test_gpt.py' with a test function for the simple_gpt() function
tests/test_art.py Added a new test file 'test_art.py' with a test function for the print_wave() function, using output capture to verify the function's behavior

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ryansurf - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider enhancing the test cases, especially for the GPT and art functionalities, to be more comprehensive. Current tests only check for basic output presence rather than specific content or behavior.
  • There's an inconsistency in import styles (e.g., changing from from src.helper import extract_decimal to from src import helper). Could you explain the reasoning behind this change and consider applying it consistently across the codebase if it's intentional?
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines 11 to 30
def test_print_wave():
"""
Testing the print_wave() function
Uses sys & io to capture printed output
"""
# Capture the output
captured_output = io.StringIO() # Create StringIO object
sys.stdout = captured_output # Redirect stdout.

# Call the function
art.print_wave(1, 0, "blue")

# Reset redirect.
sys.stdout = sys.__stdout__

# Now captured_output.getvalue() contains the printed content
output = captured_output.getvalue()

# Perform assertions based on expected output
assert output != "", "print_wave() did not print anything"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Improve test_print_wave() with more specific assertions

The current test only checks if something was printed. Consider adding assertions to verify the content of the output, such as checking for specific wave characters or color codes.

Suggested change
def test_print_wave():
"""
Testing the print_wave() function
Uses sys & io to capture printed output
"""
# Capture the output
captured_output = io.StringIO() # Create StringIO object
sys.stdout = captured_output # Redirect stdout.
# Call the function
art.print_wave(1, 0, "blue")
# Reset redirect.
sys.stdout = sys.__stdout__
# Now captured_output.getvalue() contains the printed content
output = captured_output.getvalue()
# Perform assertions based on expected output
assert output != "", "print_wave() did not print anything"
def test_print_wave():
captured_output = io.StringIO()
sys.stdout = captured_output
art.print_wave(1, 0, "blue")
sys.stdout = sys.__stdout__
output = captured_output.getvalue()
assert "~" in output, "Wave character not found in output"
assert "\033[94m" in output, "Blue color code not found in output"
assert output.count("\n") == 1, "Incorrect number of lines printed"

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

see 3 files with indirect coverage changes

@ryansurf ryansurf merged commit 4b42956 into main Aug 21, 2024
9 checks passed
@ryansurf ryansurf deleted the more_tests branch August 21, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant