Skip to content

Commit

Permalink
Black and Pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cfirth-nasa authored and asgibson committed Dec 9, 2024
1 parent 08f03d4 commit 67dea87
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_AIPlugin__init__sets_instance_values_to_given_args_when_given__headers_
mocker.patch(
ai_plugin.__name__ + ".len", return_value=pytest.gen.randint(1, 200)
) # arbitrary, from 1 to 200 (but > 0)
mocker.patch(ai_plugin.__name__ + '.ServiceManager')
mocker.patch(ai_plugin.__name__ + ".ServiceManager")

# Act
cut.__init__(arg__name, arg__headers)
Expand All @@ -138,21 +138,25 @@ def test_AIPlugin__init__sets_instance_values_to_given_args_when_given__headers_
assert cut.component_name == arg__name
assert cut.headers == arg__headers

def test_AIPlugin__init__sets_service_manager_to_instantiation_of_ServiceManager_class(mocker):

def test_AIPlugin__init__sets_service_manager_to_instantiation_of_ServiceManager_class(
mocker,
):
# Arrange
arg__name = MagicMock()
arg__headers = MagicMock()
fake_service_manager = MagicMock()

mocker.patch.object(arg__headers, '__len__', return_value=2)
mocker.patch.object(arg__headers, "__len__", return_value=2)

cut = FakeAIPlugin.__new__(FakeAIPlugin)

mocker.patch(ai_plugin.__name__ + '.ServiceManager', return_value=fake_service_manager)
mocker.patch(
ai_plugin.__name__ + ".ServiceManager", return_value=fake_service_manager
)

# Act
cut.__init__(arg__name, arg__headers)

# Assert
assert cut.service_manager == fake_service_manager

32 changes: 21 additions & 11 deletions test/plugins/csv_output/test_csv_output_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_csv_output_plugin_init_initalizes_expected_default_variables(mocker):

cut = CSV_Output.__new__(CSV_Output)

mocker.patch('onair.src.ai_components.ai_plugin_abstract.ai_plugin.ServiceManager')
mocker.patch("onair.src.ai_components.ai_plugin_abstract.ai_plugin.ServiceManager")

# Act

Expand Down Expand Up @@ -56,7 +56,7 @@ def test_csv_output_plugin_update_adds_plugins_to_headers_on_first_frame(mocker)
intial_headers = copy(cut.headers)
expected_headers = intial_headers + ["plugin1", "plugin2", "plugin3"]

mocker.patch('onair.src.ai_components.ai_plugin_abstract.ai_plugin.ServiceManager')
mocker.patch("onair.src.ai_components.ai_plugin_abstract.ai_plugin.ServiceManager")

# Act
cut.update([], high_level_data)
Expand All @@ -65,7 +65,9 @@ def test_csv_output_plugin_update_adds_plugins_to_headers_on_first_frame(mocker)
assert cut.headers == expected_headers


def test_csv_output_plugin_update_does_not_add_headers_on_first_frame_when_missing_plugins(mocker):
def test_csv_output_plugin_update_does_not_add_headers_on_first_frame_when_missing_plugins(
mocker,
):
# Arrange
fake_headers = ["header1", "header2"]
cut = CSV_Output.__new__(CSV_Output)
Expand All @@ -84,7 +86,9 @@ def test_csv_output_plugin_update_does_not_add_headers_on_first_frame_when_missi
assert cut.headers == expected_headers


def test_csv_output_plugin_update_does_not_add_headers_on_first_frame_when_missing_layers(mocker):
def test_csv_output_plugin_update_does_not_add_headers_on_first_frame_when_missing_layers(
mocker,
):
# Arrange
fake_headers = ["header1", "header2"]
cut = CSV_Output.__new__(CSV_Output)
Expand All @@ -98,7 +102,7 @@ def test_csv_output_plugin_update_does_not_add_headers_on_first_frame_when_missi

# Act
cut.update([], high_level_data)

# Assert
assert cut.headers == expected_headers

Expand All @@ -115,7 +119,7 @@ def test_csv_output_plugin_update_skips_headers_after_first_frame(mocker):

# Act
cut.update(low_level_data=[], high_level_data={})

# Assert
assert cut.headers == expected_headers

Expand All @@ -127,7 +131,7 @@ def test_csv_output_plugin_update_leaves_buffer_empty_when_given_no_data(mocker)

# Act
cut.update(low_level_data=[], high_level_data={})

# Assert
assert cut.current_buffer == []

Expand Down Expand Up @@ -166,7 +170,9 @@ def test_csv_output_plugin_update_fills_buffer_with_high_level_data(mocker):
assert cut.current_buffer == expected_buffer


def test_csv_output_plugin_render_reasoning_creates_expected_file_on_first_frame(mocker):
def test_csv_output_plugin_render_reasoning_creates_expected_file_on_first_frame(
mocker,
):
# Arrange
cut = CSV_Output.__new__(CSV_Output)
cut.filename_preamble = "test_"
Expand All @@ -188,8 +194,10 @@ def test_csv_output_plugin_render_reasoning_creates_expected_file_on_first_frame
os.remove(cut.file_name)


def test_csv_output_plugin_render_reasoning_does_not_create_new_file_when_not_first_frame(mocker):
# Arrange
def test_csv_output_plugin_render_reasoning_does_not_create_new_file_when_not_first_frame(
mocker,
):
# Arrange
cut = CSV_Output.__new__(CSV_Output)
cut.filename_preamble = "test_"
cut.first_frame = True
Expand Down Expand Up @@ -226,7 +234,9 @@ def test_csv_output_plugin_render_reasoning_does_not_create_new_file_when_not_fi
os.remove(target_file_name)


def test_csv_output_plugin_render_reasoning_changes_file_when_lines_per_file_reached(mocker):
def test_csv_output_plugin_render_reasoning_changes_file_when_lines_per_file_reached(
mocker,
):
# Arrange
cut = CSV_Output.__new__(CSV_Output)
cut.filename_preamble = "test_"
Expand Down

0 comments on commit 67dea87

Please sign in to comment.