forked from anvilco/python-anvil
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
39 lines (28 loc) · 1.32 KB
/
test_utils.py
File metadata and controls
39 lines (28 loc) · 1.32 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
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned,singleton-comparison
from python_anvil.utils import build_batch_filenames, camel_to_snake, create_unique_id
def describe_build_batch_filenames():
def test_with_normal_filename():
gen = build_batch_filenames("somefile.txt")
assert next(gen) == "somefile-0.txt"
assert next(gen) == "somefile-1.txt"
def test_with_start_index():
gen = build_batch_filenames("somefile.txt", start_idx=100)
assert next(gen) == "somefile-100.txt"
assert next(gen) == "somefile-101.txt"
def test_with_separator():
gen = build_batch_filenames("somefile.txt", separator=":::")
assert next(gen) == "somefile:::0.txt"
def test_with_all():
gen = build_batch_filenames("somefile.txt", start_idx=555, separator=":::")
assert next(gen) == "somefile:::555.txt"
def describe_create_unique_id():
def test_no_prefix():
assert create_unique_id().startswith("field-")
def test_prefix():
prefix = "somePrefix+++--"
assert create_unique_id(prefix).startswith(prefix)
def describe_camel_to_snake():
def test_it():
assert camel_to_snake('oneToTwo') == 'one_to_two'
assert camel_to_snake('one') == 'one'
assert camel_to_snake('TwoTwo') == 'two_two'