Skip to content

Commit

Permalink
Merge pull request #109 from rl-institut/fix/startup
Browse files Browse the repository at this point in the history
Change startup to ease user experience of the tool
  • Loading branch information
Bachibouzouk authored Jan 30, 2020
2 parents 1ecace0 + 390701b commit 92c2918
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Here is a template for new release sections
## [Unreleased]

### Added

### Changed

### Removed
- test for running the main function (#109)
- the user can run the tool simply with `python mvs_tool.py` (#109)
### Fixed
- \#108 (#109)



Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ To set up the MVS, follow the steps below:
* Test if the MVS is running by executing
`python mvs_eland_tool/mvs_eland_tool.py`
`python mvs_tool.py`
* You can also run all existing tests by executing
Expand All @@ -90,15 +90,15 @@ To set up the MVS, follow the steps below:
To run the MVS with custom inputs, edit the json input file and run
`python mvs_eland_tool/mvs_eland_tool.py -i path_input_file -o path_output_folder`
`python mvs_tool.py -i path_input_file -o path_output_folder`
With `path_input_file`: path to json input file
and `path_output_folder`: path of the folder where simulation results should be stored
For more information about the possible command lines
`python mvs_eland_tool/mvs_eland_tool.py -h`
`python mvs_tool.py -h`
## Contributing
Expand Down
2 changes: 1 addition & 1 deletion mvs_eland_tool/mvs_eland_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main(**kwargs):
# # todo: is user input completely used?
# dict_values = data_input.load_json(user_input["path_input_file"])

if not kwargs["path_input_file"].endswith("json"):
if not user_input["path_input_file"].endswith("json"):
logging.debug("Accessing script: A1_csv_to_json")
path_to_json_from_csv = load_data_from_csv.create_input_json()
user_input.update({"path_input_file": path_to_json_from_csv})
Expand Down
4 changes: 4 additions & 0 deletions mvs_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from mvs_eland_tool.mvs_eland_tool import main

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions tests/test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ graphviz==0.13
sphinx==2.2.2
coverage==4.5
python-coveralls==2.9.3
mock==3.0.5
27 changes: 24 additions & 3 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import pytest
import os
import sys
import argparse
import shutil
import mock
import pytest

from mvs_eland_tool.mvs_eland_tool import main

OUTPUT_PATH = os.path.join(".", "tests", "MVS_outputs_simulation")


def setup_module():
if os.path.exists(OUTPUT_PATH):
shutil.rmtree(OUTPUT_PATH, ignore_errors=True)

def test_run_smoothly():
# Ensure that code does not terminate

# this ensure that the test is only ran if explicitly executed, ie not when the `pytest` command
# alone it called
@pytest.mark.skipif(
"tests/test_simulation.py" not in sys.argv, reason="requires python3.3"
)
@mock.patch("argparse.ArgumentParser.parse_args", return_value=argparse.Namespace())
def test_run_smoothly(mock_args):
main(path_output_folder=OUTPUT_PATH)
assert 1 == 1


def teardown_module():
shutil.rmtree(OUTPUT_PATH, ignore_errors=True)

0 comments on commit 92c2918

Please sign in to comment.