def test_args_version(): args_mock = mock.Mock() args_mock.return_value = Node(name="test",version=True) cli.parse_args = args_mock with output_util.captured_output() as (out, err): with pytest.raises(SystemExit): cli.main() assert VERSION == out.getvalue()
def test_print_tree_yaml(monkeypatch): gl = gitlab_util.create_test_gitlab(monkeypatch) gl.load_tree() from gitlabber.format import PrintFormat import yaml with output_util.captured_output() as (out, err): gl.print_tree(PrintFormat.YAML) output = yaml.safe_load(out.getvalue()) with open(gitlab_util.YAML_TEST_OUTPUT_FILE, 'r') as yamlFile: output_file = yaml.safe_load(yamlFile) assert yaml.dump(output_file) == yaml.dump(output)
def test_print_tree_json(monkeypatch): gl = gitlab_util.create_test_gitlab(monkeypatch) gl.load_tree() from gitlabber.format import PrintFormat import json with output_util.captured_output() as (out, err): gl.print_tree(PrintFormat.JSON) output = json.loads(out.getvalue()) with open(gitlab_util.JSON_TEST_OUTPUT_FILE, 'r') as jsonFile: output_file = json.load(jsonFile) assert json.dumps(output_file, sort_keys=True, indent=2) == json.dumps( output, sort_keys=True, indent=2)