Completed
Push — master ( 1edd10...57e203 )
by
unknown
01:17
created

test_finds_local_repo()   A

Complexity

Conditions 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
1
# -*- coding: utf-8 -*-
2
from cookiecutter import repository, exceptions
3
4
import pytest
5
6
7
def test_finds_local_repo():
8
    """A valid local repository should be returned."""
9
    project_dir = repository.determine_repo_dir(
10
        'tests/fake-repo',
11
        abbreviations={},
12
        clone_to_dir=None,
13
        checkout=None,
14
        no_input=True
15
    )
16
17
    assert 'tests/fake-repo' == project_dir
18
19
20
def test_local_repo_with_no_context_raises():
21
    """A local repository without a cookiecutter.json should raise a
22
    `RepositoryNotFound` exception.
23
    """
24
    with pytest.raises(exceptions.RepositoryNotFound) as err:
25
        repository.determine_repo_dir(
26
            'tests/fake-repo-bad',
27
            abbreviations={},
28
            clone_to_dir=None,
29
            checkout=None,
30
            no_input=True
31
        )
32
33
    assert str(err.value) == (
34
        'The repository tests/fake-repo-bad could not be located or does not '
35
        'contain a "cookiecutter.json" file.'
36
    )
37
38
39
def test_local_repo_typo():
40
    """An unknown local repository should raise a `RepositoryNotFound`
41
    exception.
42
    """
43
    with pytest.raises(exceptions.RepositoryNotFound) as err:
44
        repository.determine_repo_dir(
45
            'tests/unknown-repo',
46
            abbreviations={},
47
            clone_to_dir=None,
48
            checkout=None,
49
            no_input=True
50
        )
51
52
    assert str(err.value) == (
53
        'The repository tests/unknown-repo could not be located or does not '
54
        'contain a "cookiecutter.json" file.'
55
    )
56