-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathtest_utils.py
More file actions
43 lines (35 loc) · 1.44 KB
/
test_utils.py
File metadata and controls
43 lines (35 loc) · 1.44 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
"""
Collection of test cases to test core module.
"""
import pytest
from datajoint import DataJointError
from datajoint.utils import from_camel_case, is_camel_case, to_camel_case
def test_is_camel_case():
assert is_camel_case("AllGroups")
assert not is_camel_case("All_Groups")
assert not is_camel_case("All_Groups_")
assert not is_camel_case("_AllGroups")
assert not is_camel_case("allGroups")
assert not is_camel_case("repNames")
assert not is_camel_case("10_all")
assert not is_camel_case("hello world")
assert not is_camel_case("#baisc_names")
assert not is_camel_case("alphaBeta")
assert not is_camel_case("TestΣ")
def test_from_camel_case():
assert from_camel_case("AllGroups") == "all_groups"
with pytest.raises(DataJointError):
from_camel_case("repNames")
with pytest.warns(UserWarning, match="contains underscores"):
with pytest.raises(DataJointError):
from_camel_case("10_all")
with pytest.raises(DataJointError):
from_camel_case("hello world")
with pytest.warns(UserWarning, match="contains underscores"):
with pytest.raises(DataJointError):
from_camel_case("#baisc_names")
def test_to_camel_case():
assert to_camel_case("all_groups") == "AllGroups"
assert to_camel_case("hello") == "Hello"
assert to_camel_case("this_is_a_sample_case") == "ThisIsASampleCase"
assert to_camel_case("This_is_Mixed") == "ThisIsMixed"