forked from datajoint/datajoint-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_plugin.py
More file actions
62 lines (47 loc) · 1.72 KB
/
test_plugin.py
File metadata and controls
62 lines (47 loc) · 1.72 KB
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
from importlib.metadata import distribution
from os import path
import pytest
import datajoint.errors as djerr
import datajoint.plugin as p
@pytest.mark.skip(reason="marked for deprecation")
def test_check_pubkey():
base_name = "datajoint"
base_dist = distribution(base_name)
pubkey_meta = base_dist.read_text("{}.pub".format(base_name))
with open(
path.join(path.abspath(path.dirname(__file__)), "..", "datajoint.pub"), "r"
) as f:
assert f.read() == pubkey_meta
def test_normal_djerror():
try:
raise djerr.DataJointError
except djerr.DataJointError as e:
assert e.__cause__ is None
def test_verified_djerror(category="connection"):
try:
curr_plugins = getattr(p, "{}_plugins".format(category))
setattr(
p,
"{}_plugins".format(category),
dict(test_plugin_id=dict(verified=True, object="example")),
)
raise djerr.DataJointError
except djerr.DataJointError as e:
setattr(p, "{}_plugins".format(category), curr_plugins)
assert e.__cause__ is None
def test_verified_djerror_type():
test_verified_djerror(category="type")
def test_unverified_djerror(category="connection"):
try:
curr_plugins = getattr(p, "{}_plugins".format(category))
setattr(
p,
"{}_plugins".format(category),
dict(test_plugin_id=dict(verified=False, object="example")),
)
raise djerr.DataJointError("hello")
except djerr.DataJointError as e:
setattr(p, "{}_plugins".format(category), curr_plugins)
assert isinstance(e.__cause__, djerr.PluginWarning)
def test_unverified_djerror_type():
test_unverified_djerror(category="type")