예제 #1
0
 def test_is_user_subscribed_false(self, mailchimp):
     """Test is_user_subscribed returns False."""
     with patch.dict(self.flask_app.config, {"MAILCHIMP_API_KEY": "k-3", "MAILCHIMP_LIST_ID": 1}):
         email = "*****@*****.**"
         nw = Newsletter()
         nw.init_app(self.flask_app)
         res = nw.is_user_subscribed(email)
         nw.client.lists.member_info.assert_called_with(1, [{"email": email}])
         assert res is False
예제 #2
0
 def test_is_user_subscribed_true(self, mailchimp):
     """Test is_user_subscribed returns True."""
     with patch.dict(self.flask_app.config, {"MAILCHIMP_API_KEY": "k-3", "MAILCHIMP_LIST_ID": 1}):
         email = "*****@*****.**"
         nw = Newsletter()
         nw.init_app(self.flask_app)
         tmp = {"data": [{"email": email}], "success_count": 1}
         nw.client.lists.member_info.return_value = tmp
         res = nw.is_user_subscribed(email)
         nw.client.lists.member_info.assert_called_with(1, [{"email": email}])
         assert res is True
예제 #3
0
 def test_is_user_subscribed_false(self, mailchimp):
     """Test is_user_subscribed returns False."""
     with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                             'MAILCHIMP_LIST_ID': 1}):
         email = '*****@*****.**'
         nw = Newsletter()
         nw.init_app(self.flask_app)
         res = nw.is_user_subscribed(email)
         nw.client.lists.member_info.assert_called_with(1,
                                                        [{'email': email}])
         assert res is False
 def test_is_user_subscribed_true(self, req_mock):
     """Test is_user_subscribed returns True."""
     with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                             'MAILCHIMP_LIST_ID': 1}):
         email = '*****@*****.**'
         nw = Newsletter()
         nw.init_app(self.flask_app)
         req_mock.side_effect = [FakeResponse(text=json.dumps(dict(status='200')),
                                            json=lambda : dict(status=200),
                                            status_code=200)]
         res, err = nw.is_user_subscribed(email)
         assert res is True, (res, err)
예제 #5
0
 def test_is_user_subscribed_true(self, mailchimp):
     """Test is_user_subscribed returns True."""
     with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                             'MAILCHIMP_LIST_ID': 1}):
         email = '*****@*****.**'
         nw = Newsletter()
         nw.init_app(self.flask_app)
         tmp = {'data': [{'email': email}],
                'success_count': 1}
         nw.client.lists.member_info.return_value = tmp
         res = nw.is_user_subscribed(email)
         nw.client.lists.member_info.assert_called_with(1,
                                                        [{'email': email}])
         assert res is True
예제 #6
0
 def test_is_user_subscribed_true(self, mailchimp):
     """Test is_user_subscribed returns True."""
     with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                             'MAILCHIMP_LIST_ID': 1}):
         email = '*****@*****.**'
         nw = Newsletter()
         nw.init_app(self.flask_app)
         tmp = {'data': [{'email': email}],
                'success_count': 1}
         nw.client.lists.member_info.return_value = tmp
         res = nw.is_user_subscribed(email)
         nw.client.lists.member_info.assert_called_with(1,
                                                        [{'email': email}])
         assert res is True