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

Added basic spinner tests and modified spinner method docstring #2855

Merged
merged 4 commits into from
Apr 22, 2023

Conversation

OmriGM
Copy link
Contributor

@OmriGM OmriGM commented Apr 21, 2023

Background

  • Improve the quality of AutoGPT by adding unit tests
  • Started adding unit tests to the Spinner class

Changes

  • Added 5 basic unit tests to the Spinner class
  • Modified the docstring of update_message method

Documentation

Test Plan

PR Quality Checklist

  • My pull request is atomic and focuses on a single change.
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes

@github-actions
Copy link
Contributor

Coverage report

The coverage rate went from 31.23% to 31.93% ⬆️
The branch rate is 18%.

None of the new lines are part of the tested code. Therefore, there is no coverage data about them.

Comment on lines +7 to +26
"""
Code Analysis

Main functionalities:
The Spinner class provides a simple way to display a spinning animation while a process is running. It can be used to indicate that a process is ongoing and to provide visual feedback to the user. The class can be used as a context manager, which means that it can be used with the 'with' statement to automatically start and stop the spinner animation.

Methods:
- __init__(self, message: str = "Loading...", delay: float = 0.1) -> None: Initializes the Spinner class with a message to display and a delay between each spinner update.
- spin(self) -> None: Spins the spinner animation while the process is running.
- __enter__(self): Starts the spinner animation when used as a context manager.
- __exit__(self, exc_type, exc_value, exc_traceback) -> None: Stops the spinner animation when used as a context manager.
- update_message(self, new_message, delay=0.1): Updates the message displayed by the spinner animation.

Fields:
- spinner: An itertools.cycle object that contains the characters used for the spinner animation.
- delay: The delay between each spinner update.
- message: The message to display.
- running: A boolean value that indicates whether the spinner animation is running.
- spinner_thread: A threading.Thread object that runs the spin method in a separate thread.
"""
Copy link
Member

Choose a reason for hiding this comment

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

Did you do this by hand or with a tool? If a tool, what tool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used CodiumAI's VSCode Extension which came pretty handy here, and it also helped writing the unit tests!

Copy link
Member

Choose a reason for hiding this comment

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

I feel like we are about to become very familiar with that tool

@ntindle ntindle added enhancement New feature or request testing labels Apr 22, 2023
@ntindle
Copy link
Member

ntindle commented Apr 22, 2023

Will you update from base so I can test the code coverage tool before we merge?

@codecov
Copy link

codecov bot commented Apr 22, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.77 🎉

Comparison is base (ca31c46) 35.52% compared to head (e09bbc4) 36.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2855      +/-   ##
==========================================
+ Coverage   35.52%   36.29%   +0.77%     
==========================================
  Files          60       60              
  Lines        2849     2849              
  Branches      471      471              
==========================================
+ Hits         1012     1034      +22     
+ Misses       1776     1753      -23     
- Partials       61       62       +1     
Impacted Files Coverage Δ
autogpt/spinner.py 96.96% <ø> (+66.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ntindle ntindle merged commit fc4b5ad into Significant-Gravitas:master Apr 22, 2023
@OmriGM OmriGM deleted the tests/basic-spinner-tests branch April 22, 2023 06:28
@ntindle
Copy link
Member

ntindle commented Apr 22, 2023

@OmriGM would love to see some more of these come through if you have the capacity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/l testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants