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, 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
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)
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