|
| 1 | +import logging |
1 | 2 | from time import sleep |
2 | | - |
| 3 | +from zenpy.lib.api import ZenpyException |
| 4 | +from zenpy import Zenpy |
3 | 5 | from test_api.fixtures import ZenpyApiTestCase |
4 | 6 |
|
5 | 7 | from test_api.fixtures.__init__ import ( |
|
36 | 38 | from zenpy.lib import util |
37 | 39 | from datetime import datetime, timezone |
38 | 40 | from unittest import TestCase |
| 41 | +from unittest.mock import MagicMock |
39 | 42 |
|
40 | 43 | class DateTimeTest(TestCase): |
41 | 44 | def test_datetime_import(self): |
@@ -428,3 +431,24 @@ def test_users_me(self): |
428 | 431 | me = self.zenpy_client.users.me() |
429 | 432 | self.assertNotEqual(me, None, "me is valid") |
430 | 433 | self.assertNotEqual(me.email, "", "email is valid in me") |
| 434 | + |
| 435 | +class TestPasswordDeprecation(ZenpyApiTestCase): |
| 436 | + __test__ = True |
| 437 | + def test_password_failure(self): |
| 438 | + log = logging.getLogger() |
| 439 | + log.error = MagicMock(return_value="error issued") |
| 440 | + with self.assertRaises(ZenpyException): |
| 441 | + zenpy_client = Zenpy(subdomain="party", email="face@toe", password="Yer", password_treatment_level="error") |
| 442 | + log.error.assert_called_once_with("ERROR **** PASSWORDS WILL BE DISABLED **** https://github.com/facetoe/zenpy/issues/651 https://support.zendesk.com/hc/en-us/articles/7386291855386-Announcing-the-deprecation-of-password-access-for-APIs") |
| 443 | + def test_password_passes(self): |
| 444 | + log = logging.getLogger() |
| 445 | + log.warning = MagicMock(return_value="warning issued") |
| 446 | + zenpy_client = Zenpy(subdomain="party", email="face@toe", password="Yer", password_treatment_level="warning") |
| 447 | + log.warning.assert_called_once_with("WARNING **** PASSWORDS WILL BE DISABLED **** https://github.com/facetoe/zenpy/issues/651 https://support.zendesk.com/hc/en-us/articles/7386291855386-Announcing-the-deprecation-of-password-access-for-APIs") |
| 448 | + |
| 449 | + def test_password_passes_no_deprecation(self): |
| 450 | + log = logging.getLogger() |
| 451 | + log.warning = MagicMock(return_value="warning issued") |
| 452 | + zenpy_client = Zenpy(subdomain="party", email="face@toe", password="Yer") |
| 453 | + log.warning.assert_called_once_with("WARNING **** PASSWORDS WILL BE DISABLED **** https://github.com/facetoe/zenpy/issues/651 https://support.zendesk.com/hc/en-us/articles/7386291855386-Announcing-the-deprecation-of-password-access-for-APIs") |
| 454 | + |
0 commit comments