-
Notifications
You must be signed in to change notification settings - Fork 1
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
3 changed files
with
74 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# !/usr/bin/python | ||
# coding: utf_8 | ||
|
||
|
||
"""Tests string implementation""" | ||
|
||
from hal.strings.models import String | ||
from hal.tests.utils import BatteryTests | ||
|
||
|
||
class TestString: | ||
"""Tests linked list""" | ||
|
||
def test_remove_escapes(self): | ||
"""Asserts removal of anything except letters and numbers""" | ||
|
||
tests = { | ||
"a": "a", | ||
"a\\a1": "a1", | ||
"a\\?A2": "aA2" | ||
} | ||
tests = { | ||
String(key).remove_escapes(): val | ||
for key, val in tests.items() | ||
} | ||
|
||
BatteryTests(tests).assert_all() | ||
|
||
def test_remove_non_ansi(self): | ||
"""Asserts removal of non ANSI chars""" | ||
|
||
tests = { | ||
"a": "a", | ||
"a\x1b[30m": "a", | ||
"a\x1b[31m": "a" | ||
} | ||
tests = { | ||
String(key).remove_non_ansi(): val | ||
for key, val in tests.items() | ||
} | ||
|
||
BatteryTests(tests).assert_all() | ||
|
||
def test_is_well_formatted(self): | ||
"""Asserts is well formatted""" | ||
|
||
tests = { | ||
"a": True, | ||
"a\n": False, | ||
"a\\t": False | ||
} | ||
tests = { | ||
String(key).is_well_formatted(): val | ||
for key, val in tests.items() | ||
} | ||
|
||
BatteryTests(tests).assert_all() | ||
|
||
def test_strip_bad_html(self): | ||
"""Asserts bad HTML stripper""" | ||
|
||
tests = { | ||
"a": True, | ||
"a\n": "a", | ||
"a\\t": "a" | ||
} | ||
tests = { | ||
String(key).strip_bad_html(): val | ||
for key, val in tests.items() | ||
} | ||
|
||
BatteryTests(tests).assert_all() |