forked from Katello/katello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
system_group_systems_test.py
68 lines (48 loc) · 2.09 KB
/
system_group_systems_test.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import unittest
import os
from katello.tests.core.action_test_utils import CLIOptionTestCase, CLIActionTestCase
from katello.tests.core.organization import organization_data
from katello.tests.core.system import system_data
import katello.client.core.system_group
from katello.client.core.system_group import Systems
class RequiredCLIOptionsTests(CLIOptionTestCase):
#requires: organization, name
action = Systems()
disallowed_options = [
(),
('--org=ACME',),
('--name=system_group_1',)
]
allowed_options = [
('--org=ACME', '--name=system_group_1')
]
class SystemGroupSystemsTest(CLIActionTestCase):
ORG = organization_data.ORGS[0]
SYSTEM_GROUP = system_data.SYSTEM_GROUPS[0]
OPTIONS = {
'org': ORG['name'],
'name': SYSTEM_GROUP['name']
}
def setUp(self):
self.set_action(Systems())
self.set_module(katello.client.core.system_group)
self.mock_printer()
self.mock_options(self.OPTIONS)
self.mock(self.module, 'get_system_group', self.SYSTEM_GROUP)
self.mock(self.action.api, 'system_group_systems', self.SYSTEM_GROUP)
def test_it_calls_the_get_system_group_util(self):
self.action.run()
self.module.get_system_group.assert_called_once_with(self.OPTIONS['org'], self.SYSTEM_GROUP['name'])
def test_it_returns_success_when_system_group_found(self):
self.assertEqual(self.action.run(), os.EX_OK)
def test_it_calls_system_group_systems_api(self):
self.action.run()
self.action.api.system_group_systems.assert_called_once_with(self.OPTIONS['org'], self.SYSTEM_GROUP['id'])
def test_it_returns_error_when_system_group_systems_not_found(self):
self.mock(self.action.api, 'system_group_systems', None)
self.assertEqual(self.action.run(), os.EX_DATAERR)
def test_it_returns_success_when_system_group_systems_found(self):
self.assertEqual(self.action.run(), os.EX_OK)
def test_it_prints_the_system_group_systems(self):
self.action.run()
self.action.printer.print_items.assert_called_once()