def test_get_name_from_metadata_bad_content_no_name(tmp_path, monkeypatch): """The metadata file is valid yaml, but there is no name.""" monkeypatch.chdir(tmp_path) # put a broken metadata metadata_file = tmp_path / 'metadata.yaml' with metadata_file.open('wb') as fh: fh.write(b"{}") result = get_name_from_metadata() assert result is None
def test_get_name_from_metadata_ok(tmp_path, monkeypatch): """The metadata file is valid yaml, but there is no name.""" monkeypatch.chdir(tmp_path) # put a valid metadata metadata_file = tmp_path / 'metadata.yaml' with metadata_file.open('wb') as fh: fh.write(b"name: test-name") result = get_name_from_metadata() assert result == "test-name"
def test_get_name_from_metadata_bad_content_garbage(tmp_path, monkeypatch): """The metadata file is broken.""" monkeypatch.chdir(tmp_path) # put a broken metadata metadata_file = tmp_path / 'metadata.yaml' with metadata_file.open('wb') as fh: fh.write(b"\b00\bff -- not a realy yaml stuff") result = get_name_from_metadata() assert result is None
def test_get_name_from_metadata_no_file(tmp_path, monkeypatch): """No metadata file to get info.""" monkeypatch.chdir(tmp_path) result = get_name_from_metadata() assert result is None