Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastiaan Huber <[email protected]>
  • Loading branch information
agoscinski and sphuber committed May 27, 2024
1 parent 5ff5655 commit a8f77fc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/cmdline/commands/test_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,18 @@ def test_computer_export_setup(self, tmp_path, sort):
exported_setup_filename = tmp_path / 'computer-setup.yml'
result = self.cli_runner(computer_export_setup, [sort, comp.label, exported_setup_filename])
assert result.exit_code == 0, 'Command should have run successfull.'
assert f'{exported_setup_filename}' in result.output, 'Filename should be in terminal output but was not found.'
assert os.path.exists(exported_setup_filename), f"'{exported_setup_filename}' was not created during export."
assert str(exported_setup_filename) in result.output, 'Filename should be in terminal output but was not found.'
assert exported_setup_filename.exists(), f"'{exported_setup_filename}' was not created during export."
# verifying correctness by comparing internal and loaded yml object
with open(exported_setup_filename, 'r', encoding='utf-8') as yfhandle:
configure_setup_data = yaml.safe_load(yfhandle)
configure_setup_data = yaml.safe_load(exported_setup_filename.read_text())
assert configure_setup_data == self.comp_builder.get_computer_spec(
comp
), 'Internal computer configuration does not agree with exported one.'

# we create a directory so we raise an error when exporting with the same name
# to test the except part of the function
already_existing_filename = tmp_path / 'tmp_dir'
os.mkdir(already_existing_filename)
already_existing_filename.mkdir()
result = self.cli_runner(computer_export_setup, [sort, comp.label, already_existing_filename], raises=True)
assert result.exit_code == ExitCode.CRITICAL

Expand Down

0 comments on commit a8f77fc

Please sign in to comment.