Completed
Push — master ( f46766...a9fd17 )
by Jace
8s
created

TestApplications   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_get_missing() 0 4 2
A test_get() 0 4 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.application import Application, Applications
6
7
8
class TestApplication:
9
10
    """Unit tests for the application class."""
11
12
    app1 = Application('iTunes')
13
    app1.versions.mac = 'iTunes.app'
14
    app2 = Application('HipChat')
15
    app3 = Application('Sublime Text')
16
    app3.versions.linux = 'sublime_text'
17
    app4 = Application('hipchat')
18
19
    str_application = [
20
        ("iTunes", app1),
21
        ("HipChat", app2),
22
        ("Sublime Text", app3),
23
        ("hipchat", app4),
24
    ]
25
26
    @pytest.mark.parametrize("string,application", str_application)
27
    def test_str(self, string, application):
28
        """Verify applications can be converted to strings."""
29
        assert string == str(application)
30
31
    def test_eq(self):
32
        """Verify applications can be equated."""
33
        assert self.app2 == self.app4
34
        assert self.app1 != self.app3
35
36
    def test_lt(self):
37
        """Verify applications can be sorted."""
38
        assert self.app2 < self.app1
39
        assert self.app3 > self.app2
40
41
42
class TestApplications:
43
44
    """Unit tests for lists of applications."""
45
46
    apps = Applications([TestApplication.app1, TestApplication.app2])
47
48
    def test_get(self):
49
        """Verify an application can be found in a list."""
50
        app = self.apps.get('itunes')
51
        assert 'iTunes' == app.name
52
53
    def test_get_missing(self):
54
        """Verify an invalid names raise an assertion."""
55
        with pytest.raises(AssertionError):
56
            self.apps.get('fake')
57