def test_load_config_aborts_if_file_does_not_match_schema(mock_open): # Arrange mock_open.return_value = StringIO( textwrap.dedent(""" commands: run: cmd: echo "./manage.py runserver" foo: bar """)) # Act # Assert with pytest.raises(InvalidYamlException): load_config("path")
def test_load_config_with_legacy_formatprints_deprecation_message( mock_open, capfd): # Arrange mock_open.return_value = StringIO( textwrap.dedent(""" - id: run cmd: echo "./manage.py runserver" - id: test cmd: - "poetry run python -m pytest" """)) # Act load_config("filename") out, err = capfd.readouterr() # Assert assert "DEPRECATION WARNING: Your plz.yaml file is using a deprecated format" in out
def test_laod_config_loads_yaml_file(mock_open): # Arrange mock_open.return_value = StringIO(u"""- id: run name: runserver cmd: echo "./manage.py runserver" """) expected_result = [{ "id": "run", "name": "runserver", "cmd": 'echo "./manage.py runserver"', }] # Act result = load_config('path') # Assert assert (result == expected_result)
def test_load_config_converts_legacy_config_to_valid_config(mock_open): # Arrange mock_open.return_value = StringIO( textwrap.dedent(""" - id: run cmd: echo "./manage.py runserver" - id: test cmd: - "poetry run python -m pytest" """)) # Act result = load_config("filename") # Assert assert type(result) == dict # Confirm validate_configuration_data does not throw an exception assert validate_configuration_data(result) == None
def test_load_config_loads_yaml_file(mock_open): # Arrange mock_open.return_value = StringIO( textwrap.dedent(""" commands: run: cmd: echo "./manage.py runserver" """)) expected_result = { "commands": { "run": { "cmd": 'echo "./manage.py runserver"' } } } # Act result = load_config("path") # Assert assert result == expected_result