003-validator.py 695 B

12345678910111213141516171819202122232425262728293031323334
  1. import pathlib
  2. import sys
  3. current = pathlib.Path(__file__)
  4. test_dir = current.parent
  5. project_dir = test_dir.parent
  6. source_dir = project_dir / pathlib.Path("source")
  7. sys.path.append(str(source_dir))
  8. import cx_apikey as apikey
  9. test_count = 0
  10. def test(tag: str, result: bool) -> None:
  11. global test_count
  12. test_count += 1
  13. print("Running test " + tag + " (" + str(test_count) + "):", end = " ")
  14. if result:
  15. print("Valid")
  16. return
  17. print("FAIL!!!")
  18. exit(-1)
  19. factory = apikey.apikey_factory("test").set_size(10)
  20. sample = factory.generate()
  21. sample_manual = "test_1234567890"
  22. bad_sample = "no_1234567890"
  23. other_bad = "test_uuuuuuuuuu"
  24. factory.get_validator()