@@ -18,6 +18,7 @@ def setUp(self):
18
18
19
19
@responses .activate
20
20
def test_get_line_item (self ):
21
+ # Tests getting a line item.
21
22
with open ('./tests/test_files/get_line_item.json' , 'r' ) as line_item_file :
22
23
line_item_json = json .load (line_item_file )
23
24
responses .add (
@@ -31,6 +32,7 @@ def test_get_line_item(self):
31
32
32
33
@responses .activate
33
34
def test_get_line_items (self ):
35
+ # Tests getting all line items for a project.
34
36
with open ('./tests/test_files/get_line_items.json' , 'r' ) as line_item_file :
35
37
line_item_json = json .load (line_item_file )
36
38
responses .add (responses .GET , '{}/sample/v1/projects/1/lineItems' .format (BASE_HOST ), json = line_item_json , status = 200 )
@@ -40,6 +42,7 @@ def test_get_line_items(self):
40
42
41
43
@responses .activate
42
44
def test_get_line_item_detailed_report (self ):
45
+ # Tests getting a line item detailed report.
43
46
with open ('./tests/test_files/get_line_item_detailed_report.json' , 'r' ) as line_item_detailed_report_file :
44
47
line_item_detailed_report_json = json .load (line_item_detailed_report_file )
45
48
responses .add (
@@ -53,7 +56,7 @@ def test_get_line_item_detailed_report(self):
53
56
54
57
@responses .activate
55
58
def test_add_line_item (self ):
56
- # Tests creating a project. This also tests validating the project data as part of `api.create_project` .
59
+ # Tests creating a line item .
57
60
with open ('./tests/test_files/create_line_item.json' , 'r' ) as new_lineitem_file :
58
61
new_lineitem_data = json .load (new_lineitem_file )
59
62
# Success response
@@ -76,9 +79,36 @@ def test_add_line_item(self):
76
79
self .api .add_line_item (24 , new_lineitem_data )
77
80
self .assertEqual (len (responses .calls ), 2 )
78
81
82
+ @responses .activate
83
+ def test_close_line_item (self ):
84
+ # Tests closing a line item.
85
+ responses .add (
86
+ responses .POST ,
87
+ '{}/sample/v1/projects/69/lineItems/1337/close' .format (BASE_HOST ),
88
+ json = {'status' : {'message' : 'success' }},
89
+ status = 200
90
+ )
91
+
92
+ # Response with error status
93
+ responses .add (
94
+ responses .POST ,
95
+ '{}/sample/v1/projects/69/lineItems/1337/close' .format (BASE_HOST ),
96
+ json = {'status' : {'message' : 'error' }},
97
+ status = 200
98
+ )
99
+
100
+ # Test successful response
101
+ self .api .close_line_item (69 , 1337 )
102
+ self .assertEqual (len (responses .calls ), 1 )
103
+
104
+ # Test error response
105
+ with self .assertRaises (DemandAPIError ):
106
+ self .api .close_line_item (69 , 1337 )
107
+ self .assertEqual (len (responses .calls ), 2 )
108
+
79
109
@responses .activate
80
110
def test_launch_line_item (self ):
81
- # Tests closing a project .
111
+ # Tests launching a line item .
82
112
responses .add (
83
113
responses .POST ,
84
114
'{}/sample/v1/projects/24/lineItems/180/launch' .format (BASE_HOST ),
@@ -131,6 +161,7 @@ def test_pause_line_item(self):
131
161
132
162
@responses .activate
133
163
def test_update_line_item (self ):
164
+ # Tests updating a line item.
134
165
with open ('./tests/test_files/update_line_item.json' , 'r' ) as new_lineitem_file :
135
166
update_lineitem_data = json .load (new_lineitem_file )
136
167
0 commit comments