aboutsummaryrefslogtreecommitdiff
path: root/autogpts/autogpt/tests/unit/test_spinner.py
blob: 9f2cbac651c1544d7ae070b09e6d02caf3d6ab3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import time

from autogpt.app.spinner import Spinner

ALMOST_DONE_MESSAGE = "Almost done..."
PLEASE_WAIT = "Please wait..."


def test_spinner_initializes_with_default_values():
    """Tests that the spinner initializes with default values."""
    with Spinner() as spinner:
        assert spinner.message == "Loading..."
        assert spinner.delay == 0.1


def test_spinner_initializes_with_custom_values():
    """Tests that the spinner initializes with custom message and delay values."""
    with Spinner(message=PLEASE_WAIT, delay=0.2) as spinner:
        assert spinner.message == PLEASE_WAIT
        assert spinner.delay == 0.2


#
def test_spinner_stops_spinning():
    """Tests that the spinner starts spinning and stops spinning without errors."""
    with Spinner() as spinner:
        time.sleep(1)
    assert not spinner.running


def test_spinner_can_be_used_as_context_manager():
    """Tests that the spinner can be used as a context manager."""
    with Spinner() as spinner:
        assert spinner.running
    assert not spinner.running