23 lines
701 B
Python
23 lines
701 B
Python
import parameterized
|
|
|
|
from stapler.strings import sanitize_string, valid_host
|
|
|
|
from . import BaseTestCase
|
|
|
|
|
|
class TestStrings(BaseTestCase):
|
|
def test_sanitize(self) -> None:
|
|
self.assertEqual("??A??", sanitize_string("\n\tA\x00\x99"))
|
|
|
|
@parameterized.parameterized.expand(
|
|
[("example.com"), ("test-test.com"), ("subdomain.example.com")]
|
|
)
|
|
def test_valid_host(self, host: str) -> None:
|
|
self.assertTrue(valid_host(host), host)
|
|
|
|
@parameterized.parameterized.expand(
|
|
[("example.c"), ("localhost"), ("127.0.0.1"), ("test..com"), ("www-.test.com")]
|
|
)
|
|
def test_invalid_host(self, host: str) -> None:
|
|
self.assertFalse(valid_host(host), host)
|