Skip to content

Commit db4cdfa

Browse files
committed
added tests
1 parent 6d871ff commit db4cdfa

File tree

3 files changed

+59
-54
lines changed

3 files changed

+59
-54
lines changed

tests/e2e/test_e2e.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def test_scrape_pubs_techteams(db, dummy_smtp):
6262
process_notifications(db, conn)
6363
assert len(dummy_smtp.sent) == 1
6464

65+
conn.close()
66+
6567

6668

6769

tests/e2e/test_scrape_pubs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
def test_scrape_pubs_techteams(db):
99
conn = db.get_connection()
1010

11-
db.add_publisher(conn, "aws", "techteam")
12-
db.add_subscription(conn, "newemail@gmail.com", enums.PublisherCategory.SOFTWARE_ENGINEERING.value, 1)
11+
db.add_publisher(conn, "facebook", "techteam")
12+
db.add_subscription(conn, "newemail5@gmail.com", enums.PublisherCategory.SOFTWARE_ENGINEERING.value, 1)
1313

1414
scrape_pubs(db, conn)
1515

1616
posts = db.get_posts(conn)
1717

1818
assert len(posts) > 10
1919

20+
conn.close()
21+
22+
2023

2124

2225

tests/e2e/test_send_email_e2e.py

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -124,55 +124,55 @@ def test_send_email_e2e(db, dummy_smtp):
124124

125125
conn.close()
126126

127-
@pytest.mark.real
128-
def test_send_email_real(db):
129-
"""
130-
End-to-end test for sending a real email via configured SMTP server.
131-
This test:
132-
- Inserts notifications into DB
133-
- Calls process_notifications (sends via real SMTP)
134-
- Verifies notifications are marked deleted
135-
- ⚠️ Actually sends an email (check inbox!)
136-
"""
137-
db_instance = db
138-
conn = db_instance.get_connection()
139-
email = "manav0611@gmail.com"
140-
141-
# Notifications from real engineering blogs
142-
notifications = [
143-
{
144-
"heading": "Google, Software Engineering",
145-
"post_title": "Announcing Android 15: What's New",
146-
"post_url": "https://android-developers.googleblog.com/2025/08/android-15-whats-new.html"
147-
},
148-
{
149-
"heading": "Facebook, Software Engineering",
150-
"post_title": "Scaling GraphQL at Meta",
151-
"post_url": "https://engineering.fb.com/2025/08/16/scaling-graphql/"
152-
},
153-
{
154-
"heading": "Stripe, Software Engineering",
155-
"post_title": "Stripe's Migration to Rust Microservices",
156-
"post_url": "https://stripe.com/blog/migration-to-rust-microservices"
157-
}
158-
]
159-
160-
# Insert notifications into DB
161-
for n in notifications:
162-
db_instance.add_notification(conn, email, n["heading"], 1, n["post_url"], n["post_title"])
163-
164-
# Process and send notifications via real SMTP
165-
process_notifications(db_instance, conn)
166-
167-
# Verify all notifications are marked deleted in DB
168-
c = conn.cursor()
169-
c.execute("""
170-
SELECT deleted FROM notifications WHERE email = ?
171-
""", (email,))
172-
rows = c.fetchall()
173-
174-
assert len(rows) == len(notifications)
175-
for r in rows:
176-
assert r[0] == 1 # deleted flag set
177-
178-
conn.close()
127+
# @pytest.mark.real
128+
# def test_send_email_real(db):
129+
# """
130+
# End-to-end test for sending a real email via configured SMTP server.
131+
# This test:
132+
# - Inserts notifications into DB
133+
# - Calls process_notifications (sends via real SMTP)
134+
# - Verifies notifications are marked deleted
135+
# - ⚠️ Actually sends an email (check inbox!)
136+
# """
137+
# db_instance = db
138+
# conn = db_instance.get_connection()
139+
# email = "manav0611@gmail.com"
140+
141+
# # Notifications from real engineering blogs
142+
# notifications = [
143+
# {
144+
# "heading": "Google, Software Engineering",
145+
# "post_title": "Announcing Android 15: What's New",
146+
# "post_url": "https://android-developers.googleblog.com/2025/08/android-15-whats-new.html"
147+
# },
148+
# {
149+
# "heading": "Facebook, Software Engineering",
150+
# "post_title": "Scaling GraphQL at Meta",
151+
# "post_url": "https://engineering.fb.com/2025/08/16/scaling-graphql/"
152+
# },
153+
# {
154+
# "heading": "Stripe, Software Engineering",
155+
# "post_title": "Stripe's Migration to Rust Microservices",
156+
# "post_url": "https://stripe.com/blog/migration-to-rust-microservices"
157+
# }
158+
# ]
159+
160+
# # Insert notifications into DB
161+
# for n in notifications:
162+
# db_instance.add_notification(conn, email, n["heading"], 1, n["post_url"], n["post_title"])
163+
164+
# # Process and send notifications via real SMTP
165+
# process_notifications(db_instance, conn)
166+
167+
# # Verify all notifications are marked deleted in DB
168+
# c = conn.cursor()
169+
# c.execute("""
170+
# SELECT deleted FROM notifications WHERE email = ?
171+
# """, (email,))
172+
# rows = c.fetchall()
173+
174+
# assert len(rows) == len(notifications)
175+
# for r in rows:
176+
# assert r[0] == 1 # deleted flag set
177+
178+
# conn.close()

0 commit comments

Comments
 (0)