Skip to content

Commit

Permalink
Remove unused config option
Browse files Browse the repository at this point in the history
  • Loading branch information
the-other-james committed Sep 25, 2023
1 parent ca08443 commit b327efd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
1 change: 0 additions & 1 deletion onair/config/default_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ TelemetryMetadataFilePath = onair/data/telemetry_configs/
MetaFile = data_physics_generation_CONFIG.json
ParserFileName = csv_parser
ParserName = CSV
SimName = CSV
PluginList = {'generic_plugin':'plugins/generic/generic_plugin.py'}

[RUN_FLAGS]
Expand Down
4 changes: 1 addition & 3 deletions onair/src/run_scripts/execution_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def __init__(self, config_file='', run_name='', save_flag=False):
# Init parsing/sim info
self.parser_file_name = ''
self.parser_name = ''
self.sim_name = ''
self.simDataParser = None
self.sim = None

Expand Down Expand Up @@ -80,7 +79,6 @@ def parse_configs(self, config_filepath):
## Parse Required Data: Names
self.parser_file_name = config['DEFAULT']['ParserFileName']
self.parser_name = config['DEFAULT']['ParserName']
self.sim_name = config['DEFAULT']['SimName']

## Parse Required Data: Plugin name to path dict
config_plugin_list = config['DEFAULT']['PluginList']
Expand Down Expand Up @@ -117,7 +115,7 @@ def parse_data(self, parser_name, parser_file_name, data_file_name, metadata_fil
self.simDataParser = data_parser

def setup_sim(self):
self.sim = Simulator(self.sim_name, self.simDataParser, self.plugin_list)
self.sim = Simulator(self.simDataParser, self.plugin_list)
try:
fls = ast.literal_eval(self.benchmarkFiles)
fp = os.path.dirname(os.path.realpath(__file__)) + '/../..' + self.benchmarkFilePath
Expand Down
3 changes: 1 addition & 2 deletions onair/src/run_scripts/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
DIAGNOSIS_INTERVAL = 100

class Simulator:
def __init__(self, simType, dataParser, plugin_list):
self.simulator = simType
def __init__(self, dataParser, plugin_list):
self.simData = dataParser

headers, tests = dataParser.get_vehicle_metadata()
Expand Down
18 changes: 5 additions & 13 deletions test/onair/src/run_scripts/test_execution_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def test_ExecutionEngine__init__sets_expected_values_but_does_no_calls_when_conf
assert cut.benchmarkIndices == ''
assert cut.parser_file_name == ''
assert cut.parser_name == ''
assert cut.sim_name == ''
assert cut.simDataParser == None
assert cut.sim == None
assert cut.save_flag == arg_save_flag
Expand Down Expand Up @@ -133,7 +132,6 @@ def test_ExecutionEngine_parse_configs_raises_KeyError_with_config_file_info_whe
'BenchmarkIndices':MagicMock(),
'ParserFileName':MagicMock(),
'ParserName':MagicMock(),
'SimName':MagicMock(),
'PluginList':MagicMock()
}
required_keys = [item for item in list(fake_default.keys()) if 'Benchmark' not in item]
Expand Down Expand Up @@ -168,7 +166,7 @@ def test_ExecutionEngine_parse_configs_raises_ValueError_when_PluginList_from_co
fake_plugin_list.body = MagicMock()
fake_default_item = MagicMock()
fake_config.__getitem__.return_value = fake_default_item
fake_default_item.__getitem__.side_effect = [fake_paths_and_filenames] * 4 + [None] * 3 + [fake_plugin_list]
fake_default_item.__getitem__.side_effect = [fake_paths_and_filenames] * 4 + [None] * 2 + [fake_plugin_list]
fake_config_read_result = MagicMock()
fake_config_read_result.__len__.return_value = 1

Expand Down Expand Up @@ -202,7 +200,7 @@ def test_ExecutionEngine_parse_configs_raises_ValueError_when_PluginList_from_co
fake_plugin_list.body.keys.__len__.return_value = 0
fake_default_item = MagicMock()
fake_config.__getitem__.return_value = fake_default_item
fake_default_item.__getitem__.side_effect = [fake_paths_and_filenames] * 4 + [None] * 3 + [fake_plugin_list]
fake_default_item.__getitem__.side_effect = [fake_paths_and_filenames] * 4 + [None] * 2 + [fake_plugin_list]
fake_config_read_result = MagicMock()
fake_config_read_result.__len__.return_value = 1

Expand Down Expand Up @@ -240,7 +238,7 @@ def test_ExecutionEngine_parse_configs_raises_FileNotFoundError_when_given_plugi
fake_temp_iter = iter([fake_plugin_name])
fake_default_item = MagicMock()
fake_config.__getitem__.return_value = fake_default_item
fake_default_item.__getitem__.side_effect = [fake_paths_and_filenames] * 4 + [None] * 3 + [fake_plugin_list]
fake_default_item.__getitem__.side_effect = [fake_paths_and_filenames] * 4 + [None] * 2 + [fake_plugin_list]
fake_config_read_result = MagicMock()
fake_config_read_result.__len__.return_value = 1

Expand Down Expand Up @@ -279,7 +277,6 @@ def test_ExecutionEngine_parse_configs_sets_all_items_without_error(mocker):
'BenchmarkIndices':MagicMock(),
'ParserFileName':MagicMock(),
'ParserName':MagicMock(),
'SimName':MagicMock(),
'PluginList':"{fake_name:fake_path}"
}
fake_run_flags = MagicMock()
Expand Down Expand Up @@ -334,7 +331,6 @@ def test_ExecutionEngine_parse_configs_sets_all_items_without_error(mocker):
assert cut.benchmarkIndices == fake_default['BenchmarkIndices']
assert cut.parser_file_name == fake_default['ParserFileName']
assert cut.parser_name == fake_default['ParserName']
assert cut.sim_name == fake_default['SimName']
assert cut.plugin_list == fake_temp_plugin_list
assert fake_run_flags.getboolean.call_count == 3
assert fake_run_flags.getboolean.call_args_list[0].args == ('IO_Flag', )
Expand All @@ -355,7 +351,6 @@ def test_ExecutionEngine_parse_configs_bypasses_benchmarks_when_access_raises_er
'MetaFile':MagicMock(),
'ParserFileName':MagicMock(),
'ParserName':MagicMock(),
'SimName':MagicMock(),
'PluginList':"{fake_name:fake_path}"
}
fake_run_flags = MagicMock()
Expand Down Expand Up @@ -407,7 +402,6 @@ def test_ExecutionEngine_parse_configs_raises_KeyError_with_config_file_info_whe
'BenchmarkIndices':MagicMock(),
'ParserFileName':MagicMock(),
'ParserName':MagicMock(),
'SimName':MagicMock(),
}
required_keys = [item for item in list(fake_default.keys()) if 'Benchmark' not in item]
missing_key = pytest.gen.choice(required_keys)
Expand Down Expand Up @@ -513,7 +507,6 @@ def __init__(self, data_file, meta_file, subsystems_breakdown):
def test_ExecutionEngine_setup_sim_sets_self_sim_to_new_Simulator_and_sets_benchmark_data_when_no_exceptions_are_encountered(mocker):
# Arrange
cut = ExecutionEngine.__new__(ExecutionEngine)
cut.sim_name = MagicMock()
cut.simDataParser = MagicMock()
cut.benchmarkFiles = MagicMock()
cut.benchmarkFilePath = MagicMock()
Expand All @@ -540,7 +533,7 @@ def test_ExecutionEngine_setup_sim_sets_self_sim_to_new_Simulator_and_sets_bench

# Assert
assert execution_engine.Simulator.call_count == 1
assert execution_engine.Simulator.call_args_list[0].args == (cut.sim_name, cut.simDataParser, cut.plugin_list)
assert execution_engine.Simulator.call_args_list[0].args == (cut.simDataParser, cut.plugin_list)
assert cut.sim == fake_sim
assert execution_engine.ast.literal_eval.call_count == 2
assert execution_engine.ast.literal_eval.call_args_list[0].args == (cut.benchmarkFiles, )
Expand All @@ -553,7 +546,6 @@ def test_ExecutionEngine_setup_sim_sets_self_sim_to_new_Simulator_and_sets_bench
def test_ExecutionEngine_setup_sim_sets_self_sim_to_new_Simulator_but_does_not_set_bencmark_data_because_exception_is_encountered(mocker):
# Arrange
cut = ExecutionEngine.__new__(ExecutionEngine)
cut.sim_name = MagicMock()
cut.simDataParser = MagicMock()
cut.benchmarkFiles = MagicMock()
cut.benchmarkFilePath = MagicMock()
Expand All @@ -579,7 +571,7 @@ def test_ExecutionEngine_setup_sim_sets_self_sim_to_new_Simulator_but_does_not_s

# Assert
assert execution_engine.Simulator.call_count == 1
assert execution_engine.Simulator.call_args_list[0].args == (cut.sim_name, cut.simDataParser, cut.plugin_list)
assert execution_engine.Simulator.call_args_list[0].args == (cut.simDataParser, cut.plugin_list)
assert cut.sim == fake_sim
assert execution_engine.ast.literal_eval.call_count == 1
assert execution_engine.ast.literal_eval.call_args_list[0].args == (cut.benchmarkFiles, )
Expand Down
4 changes: 1 addition & 3 deletions test/onair/src/run_scripts/test_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# __init__ tests
def test_Simulator__init__creates_Vehicle_and_Agent(mocker):
# Arrange
arg_simType = MagicMock()
arg_dataParser = MagicMock()
arg_plugin_list = MagicMock()

Expand All @@ -35,10 +34,9 @@ def test_Simulator__init__creates_Vehicle_and_Agent(mocker):
mocker.patch(sim.__name__ + '.Agent', return_value=fake_agent)

# Act
cut.__init__(arg_simType, arg_dataParser, arg_plugin_list)
cut.__init__(arg_dataParser, arg_plugin_list)

# Assert
assert cut.simulator == arg_simType
assert sim.VehicleRepresentation.call_count == 1
assert sim.VehicleRepresentation.call_args_list[0].args == (fake_vehicle_metadata[0], fake_vehicle_metadata[1], )
assert cut.simData == arg_dataParser
Expand Down

0 comments on commit b327efd

Please sign in to comment.