def test_value_not_exists_nested_no_key(temporary_file): expected_file = Path(temporary_file.name) expected_file.write_text("dependencies:\n supported:\n apple: banana\n") rule = YAMLValueNotExists( name="Ensure service descriptor has dependencies", path=expected_file, key="dependencies.supported.stack", value="python", ) rule.pre_task_hook() rule.task() assert expected_file.read_text( ) == "dependencies:\n supported:\n apple: banana\n" expected_file.unlink()
def test_value_not_exists_list(temporary_file): expected_file = Path(temporary_file.name) expected_file.write_text( "stack: python\ndependencies: [service1, service2]") rule = YAMLValueNotExists( name="Ensure service descriptor has dependencies", path=expected_file, key="dependencies", value="service1", ) rule.pre_task_hook() rule.task() # Because of the default flow style False, the result will be block-styled assert expected_file.read_text( ) == "stack: python\ndependencies: [service2]\n" expected_file.unlink()