File: test_metadata_config.py

package info (click to toggle)
hatch-vcs 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 200 kB
  • sloc: python: 489; sh: 6; makefile: 3
file content (34 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-FileCopyrightText: 2022-present Ofek Lev <oss@ofek.dev>
#
# SPDX-License-Identifier: MIT
import pytest

from hatch_vcs.metadata_hook import VCSMetadataHook


class TestURLs:
    def test_correct(self, new_project_basic):
        config = {'urls': {'foo': 'url'}}
        metadata_hook = VCSMetadataHook(new_project_basic, config)

        assert metadata_hook.config_urls == {'foo': 'url'}

    def test_not_table(self, new_project_basic):
        config = {'urls': 9000}
        metadata_hook = VCSMetadataHook(new_project_basic, config)

        with pytest.raises(TypeError, match='option `urls` must be a table'):
            _ = metadata_hook.config_urls

    def test_url_not_string(self, new_project_basic):
        config = {'urls': {'foo': 9000}}
        metadata_hook = VCSMetadataHook(new_project_basic, config)

        with pytest.raises(TypeError, match='URL `foo` in option `urls` must be a string'):
            _ = metadata_hook.config_urls


def test_coverage(new_project_basic):
    metadata_hook = VCSMetadataHook(new_project_basic, {})

    assert metadata_hook.config_urls is metadata_hook.config_urls