File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
tests/all/integration/api/helpers Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -164,9 +164,9 @@ def expire_pending_tickets():
164164def event_invoices_mark_due ():
165165 from app import current_app as app
166166 with app .app_context ():
167- db .session .query (EventInvoice ).\
167+ db .session .query (EventInvoice ).join ( Event ). \
168168 filter (EventInvoice .status == 'upcoming' ,
169- EventInvoice . event .ends_at >= datetime .datetime .now (),
169+ Event .ends_at >= datetime .datetime .now (),
170170 (EventInvoice .created_at + datetime .timedelta (days = 30 ) <=
171171 datetime .datetime .now ())).\
172172 update ({'status' : 'due' })
Original file line number Diff line number Diff line change 1+ import unittest
2+ import datetime
3+
4+ from app import current_app as app , db
5+ from app .factories .event_invoice import EventInvoiceFactory
6+ from app .api .helpers .db import save_to_db
7+ from app .models .event_invoice import EventInvoice
8+ from app .factories .event import EventFactoryBasic
9+ from app .api .helpers .scheduled_jobs import event_invoices_mark_due
10+
11+ from tests .all .integration .setup_database import Setup
12+ from tests .all .integration .utils import OpenEventTestCase
13+
14+
15+ class TestScheduledJobs (OpenEventTestCase ):
16+ def setUp (self ):
17+ self .app = Setup .create_app ()
18+
19+ def test_event_invoices_mark_due (self ):
20+ """Method to test marking of event invoices as due"""
21+
22+ with app .test_request_context ():
23+ event_invoice_obj = EventInvoiceFactory (event__ends_at = datetime .datetime (2019 , 7 , 20 ))
24+ save_to_db (event_invoice_obj )
25+ event_invoices_mark_due ()
26+ status = db .session .query (EventInvoice ).\
27+ filter (EventInvoice .id == event_invoice_obj .id ).first ().status
28+ self .assertEqual (status , "due" )
29+
30+
31+ if __name__ == '__main__' :
32+ unittest .main ()
You can’t perform that action at this time.
0 commit comments