|
| 1 | +import os |
| 2 | +import tempfile |
| 3 | +import pytest |
| 4 | +from unittest.mock import patch |
| 5 | +from click.testing import CliRunner |
| 6 | + |
| 7 | +import openpathsampling as paths |
| 8 | + |
| 9 | +from paths_cli.commands.contents import * |
| 10 | + |
| 11 | +def test_contents(tps_fixture): |
| 12 | + # we just do a full integration test of this one |
| 13 | + scheme, network, engine, init_conds = tps_fixture |
| 14 | + runner = CliRunner() |
| 15 | + with runner.isolated_filesystem(): |
| 16 | + storage = paths.Storage("setup.nc", 'w') |
| 17 | + for obj in tps_fixture: |
| 18 | + storage.save(obj) |
| 19 | + storage.tags['initial_conditions'] = init_conds |
| 20 | + |
| 21 | + results = runner.invoke(contents, ['setup.nc']) |
| 22 | + cwd = os.getcwd() |
| 23 | + expected = [ |
| 24 | + f"Storage @ '{cwd}/setup.nc'", |
| 25 | + "CVs: 1 item", "* x", |
| 26 | + "Volumes: 8 items", "* A", "* B", "* plus 6 unnamed items", |
| 27 | + "Engines: 2 items", "* flat", "* plus 1 unnamed item", |
| 28 | + "Networks: 1 item", "* 1 unnamed item", |
| 29 | + "Move Schemes: 1 item", "* 1 unnamed item", |
| 30 | + "Simulations: 0 items", |
| 31 | + "Tags: 1 item", "* initial_conditions", |
| 32 | + "", "Data Objects:", |
| 33 | + "Steps: 0 unnamed items", |
| 34 | + "Move Changes: 0 unnamed items", |
| 35 | + "SampleSets: 1 unnamed item", |
| 36 | + "Trajectories: 1 unnamed item", |
| 37 | + f"Snapshots: {2*len(init_conds[0])} unnamed items", "" |
| 38 | + ] |
| 39 | + assert results.exit_code == 0 |
| 40 | + assert results.output.split('\n') == expected |
| 41 | + for truth, beauty in zip(expected, results.output.split('\n')): |
| 42 | + assert truth == beauty |
0 commit comments