-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixed cron job and added tests - EVent Invoice Due Marking
- Loading branch information
1 parent
e35f8f1
commit e794ded
Showing
2 changed files
with
38 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import unittest | ||
from datetime import timedelta, datetime, timezone | ||
|
||
from app.settings import get_settings | ||
from app import current_app as app, db | ||
from app.factories.event_invoice import EventInvoiceFactory | ||
from app.api.helpers.db import save_to_db | ||
from app.factories.event import EventFactoryBasic | ||
from app.api.helpers.scheduled_jobs import event_invoices_mark_due | ||
|
||
from tests.all.integration.setup_database import Setup | ||
from tests.all.integration.utils import OpenEventTestCase | ||
|
||
|
||
class TestScheduledJobs(OpenEventTestCase): | ||
def setUp(self): | ||
self.app = Setup.create_app() | ||
|
||
def test_event_invoices_mark_due(self): | ||
"""Method to test marking of event invoices as due""" | ||
|
||
with app.test_request_context(): | ||
event_invoice_obj = EventInvoiceFactory() | ||
event_obj = EventFactoryBasic() | ||
event_obj.ends_at = datetime.date(2019, 7, 20) | ||
event_invoice_obj.event = event_obj | ||
save_to_db(event_obj) | ||
save_to_db(event_invoice_obj) | ||
event_invoices_mark_due() | ||
status = db.session.query(EventInvoice).\ | ||
filter(EventInvoice.id == event_invoice_obj.id).first().status | ||
self.assertEqual(status, "due") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |