|
7 | 7 |
|
8 | 8 | from passageidentity import PassageError |
9 | 9 | from passageidentity.openapi_client.models.app_info import AppInfo |
10 | | -from passageidentity.openapi_client.models.update_user_request import UpdateUserRequest |
11 | | -from passageidentity.openapi_client.models.user_info import UserInfo |
12 | 10 | from passageidentity.passage import Passage |
13 | 11 |
|
14 | 12 | load_dotenv() |
@@ -56,164 +54,10 @@ def test_create_magic_link() -> None: |
56 | 54 | assert magic_link.ttl == 12 # type: ignore[attr-defined] |
57 | 55 |
|
58 | 56 |
|
59 | | -def test_get_user_info_valid() -> None: |
60 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
61 | | - user = cast(UserInfo, psg.getUser(PASSAGE_USER_ID)) |
62 | | - assert user.id == PASSAGE_USER_ID |
63 | | - |
64 | | - |
65 | | -def test_get_user_info_by_identifier_valid() -> None: |
66 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
67 | | - |
68 | | - email = f.email() |
69 | | - new_user = cast(UserInfo, psg.createUser({"email": email})) # type: ignore[arg-type] |
70 | | - assert new_user.email == email |
71 | | - |
72 | | - user_by_identifier = cast(UserInfo, psg.getUserByIdentifier(email)) |
73 | | - assert user_by_identifier.id == new_user.id |
74 | | - |
75 | | - user = cast(UserInfo, psg.getUser(new_user.id)) |
76 | | - assert user.id == new_user.id |
77 | | - |
78 | | - assert user_by_identifier == user |
79 | | - assert psg.deleteUser(new_user.id) |
80 | | - |
81 | | - |
82 | | -def test_get_user_info_by_identifier_valid_upper_case() -> None: |
83 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
84 | | - |
85 | | - email = f.email() |
86 | | - new_user = cast(UserInfo, psg.createUser({"email": email})) # type: ignore[arg-type] |
87 | | - assert new_user.email == email |
88 | | - |
89 | | - user_by_identifier = cast(UserInfo, psg.getUserByIdentifier(email.upper())) |
90 | | - assert user_by_identifier.id == new_user.id |
91 | | - |
92 | | - user = cast(UserInfo, psg.getUser(new_user.id)) |
93 | | - assert user.id == new_user.id |
94 | | - |
95 | | - assert user_by_identifier == user |
96 | | - assert psg.deleteUser(new_user.id) |
97 | | - |
98 | | - |
99 | | -def test_get_user_info_by_identifier_phone_valid() -> None: |
100 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
101 | | - |
102 | | - phone = "+15005550030" |
103 | | - new_user = cast(UserInfo, psg.createUser({"phone": phone})) # type: ignore[arg-type] |
104 | | - assert new_user.phone == phone |
105 | | - |
106 | | - user_by_identifier = cast(UserInfo, psg.getUserByIdentifier(phone)) |
107 | | - assert user_by_identifier.id == new_user.id |
108 | | - |
109 | | - user = cast(UserInfo, psg.getUser(new_user.id)) |
110 | | - assert user.id == new_user.id |
111 | | - |
112 | | - assert user_by_identifier == user |
113 | | - assert psg.deleteUser(new_user.id) |
114 | | - |
115 | | - |
116 | | -def test_get_user_info_by_identifier_error() -> None: |
117 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
118 | | - |
119 | | - with pytest.raises(PassageError, match="Could not find user with identifier"): |
120 | | - psg.getUserByIdentifier("error@passage.id") |
121 | | - |
122 | | - |
123 | | -def test_activate_user() -> None: |
124 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
125 | | - user = cast(UserInfo, psg.activateUser(PASSAGE_USER_ID)) |
126 | | - assert user.status == "active" |
127 | | - |
128 | | - |
129 | | -def test_deactivate_user() -> None: |
130 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
131 | | - |
132 | | - user = cast(UserInfo, psg.getUser(PASSAGE_USER_ID)) |
133 | | - user = cast(UserInfo, psg.deactivateUser(user.id)) |
134 | | - assert user.status == "inactive" |
135 | | - |
136 | | - |
137 | | -def test_list_user_devices() -> None: |
138 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
139 | | - |
140 | | - devices = cast(list, psg.listUserDevices(PASSAGE_USER_ID)) |
141 | | - assert len(devices) == 2 |
142 | | - |
143 | | - |
144 | | -def test_update_user_phone() -> None: |
145 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
146 | | - |
147 | | - phone = "+15005550021" |
148 | | - new_user = cast(UserInfo, psg.createUser({"phone": phone})) # type: ignore[arg-type] |
149 | | - |
150 | | - phone = "+15005550022" |
151 | | - user = cast(UserInfo, psg.updateUser(new_user.id, {"phone": phone})) # type: ignore[arg-type] |
152 | | - assert user.phone == phone |
153 | | - assert psg.deleteUser(new_user.id) |
154 | | - |
155 | | - |
156 | | -def test_update_user_email() -> None: |
157 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
158 | | - |
159 | | - email = f.email() |
160 | | - req = UpdateUserRequest(email=email) |
161 | | - user = cast(UserInfo, psg.updateUser(PASSAGE_USER_ID, req)) |
162 | | - assert user.email == email |
163 | | - |
164 | | - |
165 | | -def test_update_user_with_metadata() -> None: |
166 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
167 | | - |
168 | | - email = f.email() |
169 | | - user = cast(UserInfo, psg.updateUser(PASSAGE_USER_ID, {"email": email, "user_metadata": {"example1": "qwe"}})) # type: ignore[arg-type] |
170 | | - assert user.email == email |
171 | | - assert user.user_metadata["example1"] == "qwe" # type: ignore[index] |
172 | | - |
173 | | - user = cast(UserInfo, psg.updateUser(PASSAGE_USER_ID, {"email": email, "user_metadata": {"example1": "asd"}})) # type: ignore[arg-type] |
174 | | - assert user.email == email |
175 | | - assert user.user_metadata["example1"] == "asd" # type: ignore[index] |
176 | | - |
177 | | - |
178 | | -def test_create_user_with_metadata() -> None: |
179 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
180 | | - |
181 | | - email = f.email() |
182 | | - user = cast(UserInfo, psg.createUser({"email": email, "user_metadata": {"example1": "qwe"}})) # type: ignore[arg-type] |
183 | | - assert user.email == email |
184 | | - assert user.user_metadata["example1"] == "qwe" # type: ignore[index] |
185 | | - assert psg.deleteUser(user.id) |
186 | | - |
187 | | - |
188 | | -def test_get_user_info_user_does_not_exist() -> None: |
189 | | - pass |
190 | | - |
191 | | - |
192 | | -def test_create_and_delete_user() -> None: |
193 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
194 | | - |
195 | | - email = f.email() |
196 | | - new_user = cast(UserInfo, psg.createUser({"email": email})) # type: ignore[arg-type] |
197 | | - assert new_user.email == email |
198 | | - assert psg.deleteUser(new_user.id) |
199 | | - |
200 | | - |
201 | 57 | def test_smart_link_valid() -> None: |
202 | 58 | psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
203 | 59 |
|
204 | 60 | email = f.email() |
205 | 61 | magic_link = psg.createMagicLink({"email": email}) # type: ignore[arg-type] |
206 | 62 | assert magic_link.identifier == email # type: ignore[attr-defined] |
207 | 63 | assert not magic_link.activated # type: ignore[attr-defined] |
208 | | - |
209 | | - |
210 | | -def test_sign_out() -> None: |
211 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
212 | | - |
213 | | - assert psg.signOut(PASSAGE_USER_ID) |
214 | | - |
215 | | - |
216 | | -def test_revoke_user_refresh_tokens() -> None: |
217 | | - psg = Passage(PASSAGE_APP_ID, PASSAGE_API_KEY) |
218 | | - |
219 | | - assert psg.revokeUserRefreshTokens(PASSAGE_USER_ID) |
0 commit comments