-
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 078de53
Showing
2 changed files
with
37 additions
and
4 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,32 @@ | ||
import unittest | ||
import datetime | ||
|
||
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.models.event_invoice import EventInvoice | ||
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__ends_at=datetime.datetime(2019, 7, 20)) | ||
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() |