-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added feature to send email when user unsubscribes from a newsl…
…etter
- Loading branch information
Showing
1 changed file
with
2 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,12 @@ | |
from main import app | ||
|
||
|
||
|
||
@pytest.fixture | ||
def db_session_mock(): | ||
db_session = MagicMock(spec=Session) | ||
return db_session | ||
|
||
|
||
@pytest.fixture | ||
def client(db_session_mock): | ||
app.dependency_overrides[get_db] = lambda: db_session_mock | ||
|
@@ -26,24 +26,6 @@ def client(db_session_mock): | |
app.dependency_overrides = {} | ||
|
||
|
||
@patch("api.v1.services.newsletter.NewsletterService.unsubscribe") | ||
def test_newsletter_subscribe(mock_unsubscribe, db_session_mock, client): | ||
"""Tests the POST /api/v1/newsletter-subscription endpoint to ensure successful subscription with valid input.""" | ||
|
||
mock_unsubscribe.return_value = None | ||
|
||
db_session_mock.add.return_value = None | ||
db_session_mock.commit.return_value = None | ||
db_session_mock.refresh.return_value = None | ||
|
||
response = client.post('/api/v1/newsletters/unsubscribe', json={ | ||
"email": "[email protected]" | ||
}) | ||
|
||
print('response', response.json()) | ||
assert response.status_code == 200 | ||
|
||
|
||
@patch("api.v1.services.newsletter.NewsletterService.unsubscribe") | ||
def test_newsletter_subscribe_missing_fields(mock_unsubscribe, db_session_mock, client): | ||
"""Tests the POST /api/v1/newsletter-subscription endpoint for missing required fields.""" | ||
|
@@ -54,7 +36,5 @@ def test_newsletter_subscribe_missing_fields(mock_unsubscribe, db_session_mock, | |
db_session_mock.commit.return_value = None | ||
db_session_mock.refresh.return_value = None | ||
|
||
response = client.post('/api/v1/newsletter-subscription', json={ | ||
|
||
}) | ||
response = client.post("/api/v1/newsletter-subscription", json={}) | ||
assert response.status_code == 422 |