Skip to content

Commit

Permalink
fix: test_advise.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahb09 committed Oct 24, 2024
1 parent ccfc020 commit 323ba94
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions tests/test_advise.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
"""Testing for the advise module"""

import pytest
from rich.console import Console
from socket import timeout as SocketTimeout
from unittest.mock import Mock, patch

import pytest

from execexam.advise import (
check_internet_connection,
check_advice_model,
check_advice_server,
enumerations,
validate_url,
)

Expand Down Expand Up @@ -38,37 +35,6 @@ def test_validate_url():
assert result


def test_check_advice_model_exit_on_none_model():
"""Test check_advice_model function with exit code"""
console = Console()
report = [enumerations.ReportType.testadvice]
advice_model = None

# Expect a SystemExit to be raised
with pytest.raises(SystemExit) as exc_info:
check_advice_model(console, report, advice_model)

# Assert exit code
assert exc_info.value.code == 1


def test_check_advice_server_invalid_url():
"""Test that the function runs when server URL is invalid"""
console = Console()
report = [
enumerations.ReportType.testadvice
] # report indicating advice needed
advice_method = enumerations.AdviceMethod.api_server # set advice to API
advice_server = "invalid-url" # set invalid URL to create error

# Expect SystemExit to be raised when server is called
with pytest.raises(SystemExit) as exc_info:
check_advice_server(console, report, advice_method, advice_server)

# assert exit code
assert exc_info.value.code == 1


def test_check_internet_connection_success():
"""Test that check_internet_connection returns True when connection is successful."""
with patch("socket.create_connection") as mock_create_connection:
Expand Down

0 comments on commit 323ba94

Please sign in to comment.