-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathtest_zone.py
More file actions
37 lines (29 loc) · 890 Bytes
/
test_zone.py
File metadata and controls
37 lines (29 loc) · 890 Bytes
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
from __future__ import annotations
import pytest
from hcloud.exp.zone import format_txt_record, is_txt_record_quoted
@pytest.mark.parametrize(
("value", "expected"),
[
("hello world", False),
('"hello world', False),
('"hello world"', True),
],
)
def test_is_txt_record_quoted(value: str, expected: bool):
assert is_txt_record_quoted(value) == expected
MANY_A = "a" * 255
SOME_B = "b" * 10
@pytest.mark.parametrize(
("value", "expected"),
[
("", ""),
('""', '"\\"\\""'),
("hello world", '"hello world"'),
("hello\nworld", '"hello\nworld"'),
('hello "world"', '"hello \\"world\\""'),
('hello "world', '"hello \\"world"'),
(MANY_A + SOME_B, f'"{MANY_A}" "{SOME_B}"'),
],
)
def test_format_txt_record(value: str, expected: str):
assert format_txt_record(value) == expected