|
1
|
|
|
""" |
|
2
|
|
|
Fixtures for all tests. |
|
3
|
|
|
Mainly an empty groundwork app and a plugin that inherits from the ExcelValidationPattern. |
|
4
|
|
|
""" |
|
5
|
|
|
|
|
6
|
|
|
import inspect |
|
7
|
|
|
import os |
|
8
|
|
|
import pytest |
|
9
|
|
|
|
|
10
|
|
|
from groundwork_spreadsheets import ExcelValidationPattern |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
@pytest.fixture |
|
14
|
|
|
def empty_app(): |
|
15
|
|
|
""" |
|
16
|
|
|
Loads an empty groundwork application and returns it. |
|
17
|
|
|
:return: app |
|
18
|
|
|
""" |
|
19
|
|
|
from groundwork import App |
|
20
|
|
|
app = App(config_files=[os.path.join(os.path.dirname(__file__), 'configuration.py')], plugins=[], strict=True) |
|
21
|
|
|
return app |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
def get_test_data_path(filename): |
|
25
|
|
|
""" |
|
26
|
|
|
Returns the path of a file in test_data folders. |
|
27
|
|
|
It's called from the test type directories (data_types, filtering, matrix, ...). |
|
28
|
|
|
To make it re-usable it must know who called it. It does so by inspecting the call stack. |
|
29
|
|
|
|
|
30
|
|
|
:param filename: The name of the file to build the path for |
|
31
|
|
|
:return: The path to the file. |
|
32
|
|
|
""" |
|
33
|
|
|
frame = inspect.stack()[1] |
|
34
|
|
|
py_module = inspect.getmodule(frame[0]) |
|
35
|
|
|
return os.path.join(os.path.dirname(py_module.__file__), 'test_data', filename) |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
class EmptyPlugin(ExcelValidationPattern): |
|
39
|
|
|
""" |
|
40
|
|
|
A plugin that inherits from the ExcelValidationPattern. |
|
41
|
|
|
It's used in all test cases |
|
42
|
|
|
""" |
|
43
|
|
|
def __init__(self, app, name=None, *args, **kwargs): |
|
44
|
|
|
self.name = name or self.__class__.__name__ |
|
45
|
|
|
super(EmptyPlugin, self).__init__(app, *args, **kwargs) |
|
46
|
|
|
|
|
47
|
|
|
def activate(self): |
|
48
|
|
|
""" |
|
49
|
|
|
Activates the plugin. Nothing to activate because the plugin does not register anything. |
|
50
|
|
|
Needed to fulfill the groundwork API. |
|
51
|
|
|
:return: None |
|
52
|
|
|
""" |
|
53
|
|
|
pass |
|
54
|
|
|
|
|
55
|
|
|
def deactivate(self): |
|
56
|
|
|
""" |
|
57
|
|
|
Deactivates the plugin. As nothing gets registered, there is nothing to unregister. |
|
58
|
|
|
Needed to fulfill the groundwork API. |
|
59
|
|
|
:return: None |
|
60
|
|
|
""" |
|
61
|
|
|
pass |
|
62
|
|
|
|