コード例 #1
0
ファイル: test_users.py プロジェクト: jwhitlock/basket
 def test_ctms_user_runtime_error_with_sfdc_disabled(
         self, ctms_mock, sfdc_mock):
     """If CTMS finds multiple contacts, an error is returned"""
     sfdc_mock.get.side_effect = SFDCDisabled("not enabled")
     ctms_mock.get.side_effect = CTMSMultipleContactsError(
         "token",
         "dummy",
         [
             {
                 "email": {
                     "email_id": "id_1",
                     "basket_token": "dummy"
                 }
             },
             {
                 "email": {
                     "email_id": "id_2",
                     "basket_token": "dummy"
                 }
             },
         ],
     )
     rsp = self.get(params={"token": "dummy"})
     assert rsp.status_code == 400
     assert rsp.json() == {
         "status":
         "error",
         "code":
         errors.BASKET_NETWORK_FAILURE,
         "desc": ("2 contacts returned for token='dummy' with email_ids"
                  " ['id_1', 'id_2']"),
     }
コード例 #2
0
ファイル: test_users.py プロジェクト: jwhitlock/basket
 def test_ctms_user_not_found_with_sfdc_disabled(self, ctms_mock,
                                                 sfdc_mock):
     """If CTMS return no records, return is None"""
     sfdc_mock.get.side_effect = SFDCDisabled("not enabled")
     ctms_mock.get.return_value = None
     rsp = self.get(params={"token": "dummy"})
     assert rsp.status_code == 404
コード例 #3
0
ファイル: test_users.py プロジェクト: jwhitlock/basket
 def test_ctms_user_not_configured_with_sfdc_disabled(
         self, ctms_mock, sfdc_mock):
     """If CTMS was not configured, an exception is raised"""
     sfdc_mock.get.side_effect = SFDCDisabled("not enabled")
     ctms_mock.get.side_effect = CTMSNotConfigured()
     rsp = self.get(params={"token": "dummy"})
     assert rsp.status_code == 500
     assert rsp.json() == {
         "code": errors.BASKET_EMAIL_PROVIDER_AUTH_FAILURE,
         "desc": "Email service provider auth failure",
         "status": "error",
     }
コード例 #4
0
ファイル: test_users.py プロジェクト: jwhitlock/basket
 def test_get_fxa_status_false_with_sfdc_disabled(self, ctms_mock,
                                                  sfdc_mock):
     """Should return FxA status"""
     sfdc_mock.get.side_effect = SFDCDisabled("not enabled")
     ctms_mock.get.return_value = {"email": "*****@*****.**"}
     rsp = self.get(params={"token": "dummy", "fxa": "1"})
     assert rsp.status_code == 200
     assert rsp.json() == {
         "email": "*****@*****.**",
         "has_fxa": False,
         "status": "ok",
     }
コード例 #5
0
ファイル: test_users.py プロジェクト: jwhitlock/basket
 def test_with_token_with_sfdc_disabled(self, ctms_mock, sfdc_mock):
     """Passing a token gets back that user's data"""
     sfdc_mock.get.side_effect = SFDCDisabled("not enabled")
     ctms_mock.get.return_value = {"token": "dummy"}
     rsp = self.get(params={"token": "dummy"})
     assert rsp.status_code == 200
     assert rsp.json() == {"status": "ok", "token": "dummy"}
     ctms_mock.get.assert_called_once_with(amo_id=None,
                                           email=None,
                                           fxa_id=None,
                                           sfdc_id=None,
                                           token="dummy")
コード例 #6
0
ファイル: test_users.py プロジェクト: jwhitlock/basket
 def test_ctms_user_server_error_sfdc_disabled(self, ctms_mock, sfdc_mock):
     """If CTMS has a network failure, an error is returned"""
     sfdc_mock.get.side_effect = SFDCDisabled("not enabled")
     ctms_mock.get.side_effect = self.ctms_error(500,
                                                 "CTMS is rebooting...",
                                                 "Server Error")
     rsp = self.get(params={"token": "dummy"})
     assert rsp.status_code == 400
     assert rsp.json() == {
         "status": "error",
         "code": errors.BASKET_NETWORK_FAILURE,
         "desc": "",
     }