-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,45 @@ | ||
"""Módulo de testes do módulo core.""" | ||
|
||
from unittest.mock import MagicMock | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from src.core import val | ||
|
||
pendentest_array = pd.DataFrame(["2425188908", "100", "4600041302"], index=[0], columns=["Ordem", "COD_MUNICIPIO", "Contrato"]) | ||
|
||
@pytest.fixture | ||
def mock_session(mocker) -> MagicMock: | ||
"""Mock session for testing purposes.""" | ||
mock_get_object = mocker.patch("src.core.win32com.client.GetObject") | ||
mock_sap_gui = MagicMock() | ||
mock_get_object.return_value.GetScriptingEngine.return_value.Connections = "mock_connections" | ||
return mock_sap_gui | ||
|
||
|
||
df_test = pd.DataFrame([["2425188908", "100"]], index=[0], columns=["Ordem", "COD_MUNICIPIO"]) | ||
pendentes_array = df_test.to_numpy() | ||
|
||
|
||
def test_core_val(capsys, mock_session: MagicMock) -> None: | ||
"""Teste do módulo core.val. | ||
Args: | ||
---- | ||
mock_session (MagicMock): Mock session for testing purposes. | ||
""" | ||
revalorar = False | ||
contrato = "4600041302" | ||
token = "" | ||
n_con = 0 | ||
# Test case 1: Valid input | ||
val(pendentes_array, session=mock_session, contrato=contrato, revalorar=revalorar, token=token, n_con=n_con) | ||
# Capturar a Saída | ||
captured = capsys.readouterr() | ||
print(captured.out) | ||
|
||
def test_core_val(): | ||
val() | ||
# TODO: Implementar testes | ||
# Test case 2: Empty input | ||
msg = "Nenhuma ordem para ser valorada." | ||
with pytest.raises(ValueError, match=msg): | ||
val(pendentes_array=0, session=mock_session, contrato=None, revalorar=False, token="", n_con=0) |