Completed
Pull Request — master (#58)
by Jace
02:38
created

TestMacManager   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 35
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A test_is_running_none() 0 4 2
A test_is_running_false() 0 5 2
A test_init() 0 3 2
A test_stop() 0 7 2
A test_is_running_true() 0 6 2
1
# pylint: disable=misplaced-comparison-constant,no-self-use
0 ignored issues
show
introduced by
Bad option value 'misplaced-comparison-constant'
Loading history...
2
3
import pytest
4
5
from mine.manager import get_manager, LinuxManager, MacManager, WindowsManager
6
from mine.application import Application
7
8
9 View Code Duplication
class TestLinuxManager:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10
11
    """Unit tests for the Linux manager class."""
12
13
    manager = get_manager('Linux')
14
15
    def test_init(self):
16
        """Verify the OS is detected correctly."""
17
        assert isinstance(self.manager, LinuxManager)
18
19
    def test_is_running_false(self):
20
        """Verify a process can be detected as not running."""
21
        pytest.skip("TODO: implement test")
22
        application = Application('fake-program-for-mine')
23
        application.versions.linux = 'fake_program_for_mine.sh'
24
        assert False is self.manager.is_running(application)
25
26
    @pytest.mark.linux_only
27
    def test_is_running_true(self):
28
        """Verify a process can be detected as running."""
29
        pytest.skip("TODO: implement test")
30
31
    def test_is_running_none(self):
32
        """Verify a process can be detected as untracked."""
33
        application = Application('fake-program-for-mine')
34
        assert None is self.manager.is_running(application)
35
36
37
class TestMacManager:
38
39
    """Unit tests for the Mac manager class."""
40
41
    manager = get_manager('Darwin')
42
43
    def test_init(self):
44
        """Verify the OS is detected correctly."""
45
        assert isinstance(self.manager, MacManager)
46
47
    def test_is_running_false(self):
48
        """Verify a process can be detected as not running."""
49
        application = Application('fake-program-for-mine')
50
        application.versions.mac = 'FakeProgramForMine.app'
51
        assert False is self.manager.is_running(application)
52
53
    @pytest.mark.mac_only
54
    def test_is_running_true(self):
55
        """Verify a process can be detected as running."""
56
        application = Application('finder')
57
        application.versions.mac = 'Finder.app'
58
        assert True is self.manager.is_running(application)
59
60
    def test_is_running_none(self):
61
        """Verify a process can be detected as untracked."""
62
        application = Application('fake-program-for-mine')
63
        assert None is self.manager.is_running(application)
64
65
    @pytest.mark.mac_only
66
    def test_stop(self):
67
        """Verify a process can be stopped."""
68
        application = Application('mail')
69
        application.versions.mac = 'Mail.app'
70
        self.manager.stop(application)
71
        assert not self.manager.is_running(application)
72
73
74 View Code Duplication
class TestWindowsManager:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
75
76
    """Unit tests for the Windows manager class."""
77
78
    manager = get_manager('Windows')
79
80
    def test_init(self):
81
        """Verify the OS is detected correctly."""
82
        assert isinstance(self.manager, WindowsManager)
83
84
    def test_is_running_false(self):
85
        """Verify a process can be detected as not running."""
86
        pytest.skip("TODO: implement test")
87
        application = Application('fake-program-for-mine')
88
        application.versions.windows = 'FakeProgramForMine.exe'
89
        assert False is self.manager.is_running(application)
90
91
    @pytest.mark.windows_only
92
    def test_is_running_true(self):
93
        """Verify a process can be detected as running."""
94
        pytest.skip("TODO: implement test")
95
        application = Application('explorer')
96
        application.versions.windows = 'explorer.exe'
97
        assert True is self.manager.is_running(application)
98
99
    def test_is_running_none(self):
100
        """Verify a process can be detected as untracked."""
101
        application = Application('fake-program-for-mine')
102
        assert None is self.manager.is_running(application)
103