forked from gbirke/check-translated-properties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_linecheck.py
49 lines (40 loc) · 2.01 KB
/
test_linecheck.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
import linecheck
import pytest
def test_it_returns_lines_if_key_is_not_found():
checker = linecheck.Checker({})
test_lines = ["foo=bar", "bar=baz"]
assert(test_lines == checker.get_lines(test_lines))
def test_it_omits_lines_if_key_is_found():
checker = linecheck.Checker({"foo":"boo"})
test_lines = ["foo=bar", "bar=baz"]
assert(["bar=baz"] == checker.get_lines(test_lines))
def test_it_handles_property_values_with_equal_sign():
checker = linecheck.Checker({})
test_lines = ["foo=bar", "bar=baz=quux"]
assert(test_lines == checker.get_lines(test_lines))
def test_it_returns_non_property_lines_if_key_is_not_found():
checker = linecheck.Checker({})
test_lines = ["foo=bar", "#comment", "bar=baz"]
assert(test_lines == checker.get_lines(test_lines))
test_lines = ["#comment1", "#comment2", "foo=bar", "bar=baz"]
assert(test_lines == checker.get_lines(test_lines))
def test_it_returns_non_property_lines_if_some_keys_are_not_found():
checker = linecheck.Checker({"bar":"boo"})
test_lines = ["#comment", "foo=bar", "bar=baz"]
assert(["#comment", "foo=bar"] == checker.get_lines(test_lines))
def test_it_omits_last_property_lines_if_key_is_found():
checker = linecheck.Checker({"bar":"boo"})
test_lines = ["foo=bar", "#comment1", "#comment2", "bar=baz"]
assert(["foo=bar"] == checker.get_lines(test_lines))
def test_it_treats_comments_with_equal_signs_as_non_property_lines():
checker = linecheck.Checker({})
test_lines = ["# comment=foo", "bar=baz"]
assert(test_lines == checker.get_lines(test_lines))
def test_it_recognizes_and_omits_multiline_properties_if_key_is_found():
checker = linecheck.Checker({"bar":"boo"})
test_lines = ["bar=baz \\\n","quux", "foo=bar"]
assert(["foo=bar"] == checker.get_lines(test_lines))
def test_it_recognizes_and_return_multiline_properties_if_key_is_found():
checker = linecheck.Checker({})
test_lines = ["bar=baz \\\n", "quux", "foo=bar"]
assert(test_lines == checker.get_lines(test_lines))