-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
test_order.py
46 lines (38 loc) · 1.34 KB
/
test_order.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import unittest
from flask import Request, request, jsonify
from app import current_app as app, db
from app.api.helpers.db import save_to_db
from app.factories.attendee import AttendeeFactory
from app.factories.event import EventFactoryBasic
from app.factories.order import OrderFactory
from app.models.order import Order
from app.api.helpers.db import save_to_db
from tests.all.integration.setup_database import Setup
class TestOrderUtilities(OpenEventTestCase):
def setUp(self):
self.app = Setup.create_app()
def test_order_cancellation(self):
"""Method to test order cancellation"""
with app.test_request_context():
client = app.test_client()
attendee = AttendeeFactory()
save_to_db(attendee)
obj = OrderFactory()
obj.ticket_holders = [attendee, ]
save_to_db(obj)
data = {
"data": {
"attributes": {
"status": "cancelled"
},
"type": "order",
"id": obj.id
}
}
resp = client.patch('/v1/orders/1', data=dict(
order=obj,
data=data))
res = resp.get_json()
self.assertEqual(res['status'], 'cancelled')
if __name__ == '__main__':
unittest.main()