-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_divvy.py
94 lines (65 loc) · 3.26 KB
/
test_divvy.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import pytest
from attmap import PathExAttMap
from tests.conftest import DCC_ATTRIBUTES, FILES
class DefaultDCCTests:
""" Tests the default divvvy.ComputingConfiguration object creation"""
def test_no_args(self, empty_dcc):
""" Lack of arguments does not cause failure """
empty_dcc
@pytest.mark.parametrize(argnames="attrs", argvalues=DCC_ATTRIBUTES)
def test_attrs_produced(self, attrs, empty_dcc):
""" Test if compute property is produced and is not empty """
empty_dcc[attrs]
class DCCTests:
""" Tests the divvvy.ComputingConfiguration object creation """
def test_object_creation(self, dcc):
""" Test object creation for all the available compute files in pepenv repo"""
dcc
@pytest.mark.parametrize(argnames="attrs", argvalues=DCC_ATTRIBUTES)
def test_attrs_produced(self, attrs, dcc):
""" Test if compute all properties are produced """
dcc[attrs]
class ActivatingTests:
""" Test for the activate_package method"""
def test_activating_default_package(self, dcc):
""" Test if activating the default compute package works for every case """
assert dcc.activate_package("default")
@pytest.mark.parametrize(argnames="package_idx", argvalues=[0, 1])
def test_activating_some_package(self, dcc, package_idx):
""" Test if activating the default compute package works for every case """
package = list(dcc.compute_packages.keys())[package_idx]
assert dcc.activate_package(package)
@pytest.mark.parametrize(argnames="package", argvalues=["faulty_package", "another_one", 1])
def test_not_activating_faulty_package(self, dcc, package):
""" Test if the function returns False if faulty compute package provided """
assert not dcc.activate_package(package)
class GettingActivePackageTests:
""" Test for the get_active_package method"""
def test_settings_nonempty(self, dcc):
""" Test if get_active_package produces a nonempty PathExAttMap object """
settings = dcc.get_active_package()
assert settings != PathExAttMap()
class ListingPackagesTests:
""" Test for the list_compute_packages method"""
def test_list_compute_packages_is_set(self, dcc):
""" Test if list_compute_packages returns a set"""
assert isinstance(dcc.list_compute_packages(), set)
def test_list_compute_packages_result_nonempty(self, dcc):
""" Test if result nonempty"""
assert dcc.list_compute_packages() != set()
class ResettingSettingsTests:
"""" Test for the reset_active_settings method """
def test_reset_active_settings(self, dcc):
""" Test if always succeeds -- returns True """
assert dcc.reset_active_settings()
def test_reset_active_settings_works(self, dcc):
""" Test if the settings are cleared """
dcc.reset_active_settings()
assert dcc.get_active_package() == {}
class UpdatingPackagesTests:
""" Test for the update_packages method """
@pytest.mark.parametrize(argnames="config_file", argvalues=FILES)
def test_update_packages(self, dcc, config_file):
""" Test updating does not produce empty compute packages """
dcc.update_packages(config_file)
assert dcc.compute_packages != PathExAttMap()