diff options
| author | Max Nanis | 2026-09-13 19:03:55 +0000 |
|---|---|---|
| committer | Max Nanis | 2026-09-13 19:03:55 +0000 |
| commit | 8fbe8d439b418796932aaa88297e006c714e4d13 (patch) | |
| tree | 6c800476edc1e771fc570b559d483df8d59d4324 /tests/http/test_magic.py | |
| parent | 12f6fee851b68e86af658dfa17e4a0daed457dd1 (diff) | |
| parent | 2c94f248d2438071a918fa9a30bf114ef9aa29b4 (diff) | |
| download | amt-jb-8fbe8d439b418796932aaa88297e006c714e4d13.tar.gz amt-jb-8fbe8d439b418796932aaa88297e006c714e4d13.zip | |
Merges pull request #3
Off of Amazon!!!
Diffstat (limited to 'tests/http/test_magic.py')
| -rw-r--r-- | tests/http/test_magic.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/http/test_magic.py b/tests/http/test_magic.py new file mode 100644 index 0000000..f645677 --- /dev/null +++ b/tests/http/test_magic.py @@ -0,0 +1,48 @@ +from uuid import uuid4 + +from generalresearch.redis_helper import RedisConfig + +from jb.api.magic_token import ( + consume_amt_account_link_token, + consume_magic_token, + create_amt_account_link_token, + create_magic_token, +) +from jb.models.auth import AmtAccountLink + + +class TestViewFunctions: + + def test_create_amt_account_link_token( + self, redis_config: RedisConfig, amt_worker_id: str + ): + email = f"{uuid4().hex[:8]}@jamesbillings67.com" + res = create_amt_account_link_token( + email=email, amt_worker_id=amt_worker_id, redis_config=redis_config + ) + assert isinstance(res, str) + + def test_create_and_retrieve_token( + self, redis_config: RedisConfig, amt_worker_id: str + ): + email = f"{uuid4().hex[:8]}@jamesbillings67.com" + token = create_amt_account_link_token( + email=email, amt_worker_id=amt_worker_id, redis_config=redis_config + ) + + res = consume_amt_account_link_token(token=token, redis_config=redis_config) + assert isinstance(res, AmtAccountLink) + assert res.email == email + assert res.amt_worker_id == amt_worker_id + + def test_create_magic_link(self, redis_config: RedisConfig, amt_worker_id: str): + email = f"{uuid4().hex[:8]}@jamesbillings67.com" + res = create_magic_token(user_email=email, redis_config=redis_config) + assert isinstance(res, str) + + def test_consume_magic_link(self, redis_config: RedisConfig, amt_worker_id: str): + email = f"{uuid4().hex[:8]}@jamesbillings67.com" + token = create_magic_token(user_email=email, redis_config=redis_config) + + res = consume_magic_token(token=token, redis_config=redis_config) + assert res == email |
