-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
from cf_remote.utils import parse_envfile | ||
from cf_remote.utils import check_unescaped_character, parse_envfile | ||
|
||
|
||
def test_parse_envfile(): | ||
data = parse_envfile("NTD_TEST=\"test\"") | ||
assert "NTD_TEST" in data | ||
data = parse_envfile('NTD_TEST="test"') | ||
assert "NTD_TEST" in data | ||
assert data["NTD_TEST"] == "test" | ||
|
||
data = parse_envfile("NTD_X\"test\"") | ||
assert not data | ||
data = parse_envfile('NTD_TEST=""helloworld""') | ||
assert data["NTD_TEST"] == "helloworld" | ||
|
||
data = parse_envfile("=\"test\"") | ||
assert not data | ||
data = parse_envfile('NTD_TEST="\\nhello"') | ||
assert data["NTD_TEST"] == "\nhello" | ||
|
||
data = parse_envfile("NTD_test=\"test\"") | ||
assert not data | ||
|
||
data = parse_envfile("NTD_TEST=\"hello\"world\"") | ||
assert "\"" in data["NTD_TEST"] | ||
data = parse_envfile('NTD_TEST="test"\nNTD_NEWLINE="newline"') | ||
assert len(data) == 2 | ||
|
||
data = parse_envfile("NTD_TEST=\"test\"\\n\"newline\"") | ||
data = parse_envfile('NTD_TEST="NTD_TEST_TWO="test"\\nhello"') | ||
assert len(data) == 1 | ||
|
||
data = parse_envfile("NTD_TEST=\"test\"\nnNTD_NEWLINE=\"newline\"") | ||
assert len(data) == 1 | ||
|
||
data = parse_envfile("NTD_TEST=\"test\"\nNTD_NEWLINE=\"newline\"") | ||
assert len(data) == 2 | ||
def test_check_unescaped_character(): | ||
assert check_unescaped_character(r"test", '"') | ||
assert check_unescaped_character(r"\"test\"", '"') | ||
assert not check_unescaped_character(r'hello"world', '"') | ||
assert not check_unescaped_character(r'hello\""world', '"') |