1
|
|
|
# pylint: disable=no-self-use |
|
|
|
|
2
|
|
|
|
3
|
|
|
from unittest.mock import patch, call |
4
|
|
|
|
5
|
|
|
from gdm import plugin |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class TestMain: |
9
|
|
|
|
10
|
|
|
"""Unit tests for the top-level arguments.""" |
11
|
|
|
|
12
|
|
|
@patch('gdm.cli.commands') |
13
|
|
|
def test_install(self, mock_commands): |
14
|
|
|
"""Verify 'install' is the default command.""" |
15
|
|
|
mock_commands.install.__name__ = 'mock' |
16
|
|
|
|
17
|
|
|
plugin.main([]) |
18
|
|
|
|
19
|
|
|
assert [ |
20
|
|
|
call.install(root=None, depth=None, |
21
|
|
|
clean=False, fetch=True, force=False), |
22
|
|
|
call.install().__bool__(), # command status check |
23
|
|
|
] == mock_commands.mock_calls |
24
|
|
|
|
25
|
|
|
@patch('gdm.cli.commands') |
26
|
|
|
def test_update(self, mock_commands): |
27
|
|
|
"""Verify 'update' can be called with cleaning.""" |
28
|
|
|
mock_commands.update.__name__ = 'mock' |
29
|
|
|
|
30
|
|
|
plugin.main(['--update', '--clean']) |
31
|
|
|
|
32
|
|
|
assert [ |
33
|
|
|
call.update(root=None, depth=None, |
34
|
|
|
clean=True, force=False, recurse=False, lock=True), |
35
|
|
|
call.update().__bool__(), # command status check |
36
|
|
|
] == mock_commands.mock_calls |
37
|
|
|
|
38
|
|
|
@patch('gdm.cli.commands') |
39
|
|
|
def test_update_recursive(self, mock_commands): |
40
|
|
|
"""Verify 'update' can be called recursively.""" |
41
|
|
|
mock_commands.update.__name__ = 'mock' |
42
|
|
|
|
43
|
|
|
plugin.main(['--update', '--all']) |
44
|
|
|
|
45
|
|
|
assert [ |
46
|
|
|
call.update(root=None, depth=None, |
47
|
|
|
clean=False, force=False, recurse=True, lock=True), |
48
|
|
|
call.update().__bool__(), # command status check |
49
|
|
|
] == mock_commands.mock_calls |
50
|
|
|
|
51
|
|
|
@patch('gdm.cli.commands') |
52
|
|
|
def test_update_no_lock(self, mock_commands): |
53
|
|
|
"""Verify 'update' can be called without locking.""" |
54
|
|
|
mock_commands.update.__name__ = 'mock' |
55
|
|
|
|
56
|
|
|
plugin.main(['--update', '--no-lock']) |
57
|
|
|
|
58
|
|
|
assert [ |
59
|
|
|
call.update(root=None, depth=None, |
60
|
|
|
clean=False, force=False, recurse=False, lock=False), |
61
|
|
|
call.update().__bool__(), # command status check |
62
|
|
|
] == mock_commands.mock_calls |
63
|
|
|
|
64
|
|
|
@patch('gdm.cli.commands') |
65
|
|
|
def test_list(self, mock_commands): |
66
|
|
|
"""Verify 'list' can be called.""" |
67
|
|
|
mock_commands.display.__name__ = 'mock' |
68
|
|
|
|
69
|
|
|
plugin.main(['--list']) |
70
|
|
|
|
71
|
|
|
assert [ |
72
|
|
|
call.display(root=None, depth=None, |
73
|
|
|
allow_dirty=True), |
74
|
|
|
call.display().__bool__(), # command status check |
75
|
|
|
] == mock_commands.mock_calls |
76
|
|
|
|
77
|
|
|
@patch('gdm.cli.commands') |
78
|
|
|
def test_uninstall(self, mock_commands): |
79
|
|
|
"""Verify 'clean' can be called with force.""" |
80
|
|
|
mock_commands.delete.__name__ = 'mock' |
81
|
|
|
|
82
|
|
|
plugin.main(['--uninstall', '--force']) |
83
|
|
|
|
84
|
|
|
assert [ |
85
|
|
|
call.delete(root=None, force=True), |
86
|
|
|
call.delete().__bool__(), # command status check |
87
|
|
|
] == mock_commands.mock_calls |
88
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.