Ignore S101 on workspace level and fix some tests

This commit is contained in:
Theodore Aptekarev
2023-09-04 11:56:06 +02:00
parent d6b04ca9e7
commit dce9912c34
3 changed files with 25 additions and 24 deletions

View File

@@ -10,17 +10,17 @@ from openbb_provider.abstract.data import Data
def test_OBBject():
"""Smoke test."""
co = OBBject()
assert isinstance(co, OBBject) # noqa: S101
assert isinstance(co, OBBject)
def test_fields():
"""Smoke test."""
fields = OBBject.__fields__.keys()
assert "results" in fields # noqa: S101
assert "provider" in fields # noqa: S101
assert "warnings" in fields # noqa: S101
assert "chart" in fields # noqa: S101
assert "results" in fields
assert "provider" in fields
assert "warnings" in fields
assert "chart" in fields
def test_to_dataframe_no_results():
@@ -182,12 +182,12 @@ def test_to_dataframe(results, expected_df):
# Act and Assert
if isinstance(expected_df, pd.DataFrame):
result = co.to_dataframe()
assert result.equals(expected_df) # noqa: S101
assert result.equals(expected_df)
else:
with pytest.raises(expected_df.__class__) as exc_info:
co.to_dataframe()
assert str(exc_info.value) == str(expected_df) # noqa: S101
assert str(exc_info.value) == str(expected_df)
@pytest.mark.parametrize(
@@ -224,12 +224,12 @@ def test_to_dict(results, expected):
with pytest.raises(expected.__class__) as exc_info:
co.to_dict()
assert str(exc_info.value) == str(expected) # noqa: S101
assert str(exc_info.value) == str(expected)
else:
result = co.to_dict()
result.pop("index", None)
assert result == expected # noqa: S101
assert result == expected
@patch("openbb_core.app.charting_manager.ChartingManager.to_chart")
@@ -249,8 +249,8 @@ def test_to_chart_with_existing_chart(mock_to_dataframe, mock_to_chart):
result = mock_instance.to_chart()
# Assert
assert result == {"fig": "some_mock_fig"} # noqa: S101
assert mock_instance.chart.content == {"content": "some_new_content"} # noqa: S101
assert result == {"fig": "some_mock_fig"}
assert mock_instance.chart.content == {"content": "some_new_content"}
mock_to_dataframe.assert_called_once()
@@ -284,8 +284,8 @@ def test_to_chart_with_new_chart(
result = mock_instance.to_chart()
# Assert
assert result == {"fig": "some_mock_fig"} # noqa: S101
assert mock_instance.chart.content == {"content": "some_new_content"} # noqa: S101
assert result == {"fig": "some_mock_fig"}
assert mock_instance.chart.content == {"content": "some_new_content"}
# Ensure self.to_dataframe() was called
mock_to_dataframe.assert_called_once()

View File

@@ -16,7 +16,7 @@ def setup_and_teardown():
def test_charting_manager():
"""Smoke test."""
assert ChartingManager() is not None # noqa: S101
assert ChartingManager() is not None
def test_charting_manager_singleton_prop():
@@ -24,7 +24,7 @@ def test_charting_manager_singleton_prop():
cm_1 = ChartingManager()
cm_2 = ChartingManager()
assert cm_1 is cm_2 # noqa: S101
assert cm_1 is cm_2
def test_charting_settings():
@@ -34,8 +34,8 @@ def test_charting_settings():
cm = ChartingManager(user_settings=user, system_settings=sys)
assert cm.charting_settings.plot_enable_pywry is False # noqa: S101
assert cm.charting_settings.test_mode is True # noqa: S101
assert cm.charting_settings.plot_enable_pywry is False
assert cm.charting_settings.test_mode is True
def test_charting_settings_setter():
@@ -47,8 +47,8 @@ def test_charting_settings_setter():
cm.charting_settings = (sys, user)
assert cm.charting_settings.plot_enable_pywry is False # noqa: S101
assert cm.charting_settings.test_mode is True # noqa: S101
assert cm.charting_settings.plot_enable_pywry is False
assert cm.charting_settings.test_mode is True
def test_check_charting_extension_installed():
@@ -58,9 +58,7 @@ def test_check_charting_extension_installed():
try:
import openbb_charting # pylint: disable=unused-import,import-outside-toplevel # noqa: F401,E501
assert cm.check_charting_extension_installed("charting") is True # noqa: S101
assert cm.check_charting_extension_installed("charting") is True
except ImportError:
assert cm.check_charting_extension_installed("charting") is False # noqa: S101
assert ( # noqa: S101
cm.check_charting_extension_installed("openbb_core_extension_2") is False
)
assert cm.check_charting_extension_installed("charting") is False
assert cm.check_charting_extension_installed("openbb_core_extension_2") is False

3
pyproject.toml vendored
View File

@@ -193,6 +193,9 @@ convention = "numpy"
match = '((?!test_).)*\.py'
add-ignore = "D401"
[tool.flake8]
max-line-length = 122
ignore = "S101"
[tool.ruff]
line-length = 122