Onionr/tests/test_stringvalidations.py

26 lines
744 B
Python
Raw Normal View History

2019-02-14 23:48:41 +00:00
#!/usr/bin/env python3
import sys, os
sys.path.append(".")
2019-11-21 09:26:23 +00:00
sys.path.append("src/")
2019-02-15 03:28:41 +00:00
import unittest, uuid
2019-02-14 23:48:41 +00:00
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
print("Test directory:", TEST_DIR)
os.environ["ONIONR_HOME"] = TEST_DIR
from onionrutils import stringvalidators
2019-02-14 23:48:41 +00:00
class OnionrValidations(unittest.TestCase):
2019-02-14 23:48:41 +00:00
def test_integer_string(self):
valid = ["1", "100", 100, "-5", -5]
invalid = ['test', "1d3434", "1e100", None]
for x in valid:
2019-02-15 03:28:41 +00:00
#print('testing', x)
self.assertTrue(stringvalidators.is_integer_string(x))
2019-02-14 23:48:41 +00:00
for x in invalid:
2019-02-15 03:28:41 +00:00
#print('testing', x)
self.assertFalse(stringvalidators.is_integer_string(x))
2019-09-13 02:22:25 +00:00
unittest.main()