Completed
Push — master ( 471a4d...6ed34d )
by Arma
06:19
created

test_run_st2incubator_expands()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 1
1
import yaml
2
3
from st2tests.base import BaseActionTestCase
4
5
from expand_repo_name import ExpandRepoName
6
7
__all__ = [
8
    'ExpandRepoNameTestCase'
9
]
10
11
MOCK_CONFIG_BLANK = ""
12
13
MOCK_CONFIG_BLANK_REPOSITORIES = "repositories:"
14
15
MOCK_CONFIG_FULL= """
16
repositories:
17
  st2contrib:
18
    repo: "https://github.com/StackStorm/st2contrib.git"
19
    subtree: true
20
    auto_deployment:
21
      branch: "master"
22
      notify_channel: "community"
23
24
  st2incubator:
25
    repo: "https://github.com/StackStorm/st2incubator.git"
26
    subtree: true
27
    auto_deployment:
28
      branch: "master"
29
      notify_channel: "community"
30
"""
31
32
class ExpandRepoNameTestCase(BaseActionTestCase):
33
    def test_run_config_blank(self):
34
        config = yaml.safe_load(MOCK_CONFIG_BLANK)
35
        action = ExpandRepoName(config)
36
37
        self.assertRaises(Exception, action.run,
38
                          repo_name="st2contrib")
39
40
    def test_run_repositories_blank(self):
41
        config = yaml.safe_load(MOCK_CONFIG_BLANK_REPOSITORIES)
42
        action = ExpandRepoName(config)
43
44
        self.assertRaises(Exception, action.run,
45
                          repo_name="st2contrib")
46
47
    def test_run_st2contrib_expands(self):
48
        config = yaml.safe_load(MOCK_CONFIG_FULL)
49
        action = ExpandRepoName(config)
50
51
        expected = {'repo_url': 'https://github.com/StackStorm/st2contrib.git', 'subtree': True}
52
53
        result = action.run(repo_name="st2contrib")
54
        self.assertEqual(result, expected)
55
56
    def test_run_st2incubator_expands(self):
57
        config = yaml.safe_load(MOCK_CONFIG_FULL)
58
        action = ExpandRepoName(config)
59
60
        expected = {'repo_url': 'https://github.com/StackStorm/st2incubator.git', 'subtree': True}
61
62
        result = action.run(repo_name="st2incubator")
63
        self.assertEqual(result, expected)
64