| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import pathlib
- import sys
- current = pathlib.Path(__file__)
- test_dir = current.parent
- project_dir = test_dir.parent
- source_dir = project_dir / pathlib.Path("source")
- sys.path.append(str(source_dir))
- import cx_apikey as apikey
- test_count = 0
- def test(tag: str, result: bool) -> None:
- global test_count
- test_count += 1
- print("Running test " + tag + " (" + str(test_count) + "):", end = " ")
- if result:
- print("Valid")
- return
- print("FAIL!!!")
- exit(-1)
- factory = apikey.apikey_factory("test").set_size(64)
- sample_1 = factory.generate()
- sample_2 = factory.generate()
- sample_1_string = sample_1.content
- test("compare different", sample_1 != sample_2)
- test("compare different string", sample_1 != str(sample_2))
- test("compare self", sample_1 == sample_1)
- test("compare self as content", sample_1 == sample_1_string)
- test("compare self as string", sample_1 == str(sample_1))
|