@@ -18,6 +18,7 @@ def setUp(self):
1818
1919 @responses .activate
2020 def test_get_line_item (self ):
21+ # Tests getting a line item.
2122 with open ('./tests/test_files/get_line_item.json' , 'r' ) as line_item_file :
2223 line_item_json = json .load (line_item_file )
2324 responses .add (
@@ -31,6 +32,7 @@ def test_get_line_item(self):
3132
3233 @responses .activate
3334 def test_get_line_items (self ):
35+ # Tests getting all line items for a project.
3436 with open ('./tests/test_files/get_line_items.json' , 'r' ) as line_item_file :
3537 line_item_json = json .load (line_item_file )
3638 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):
4042
4143 @responses .activate
4244 def test_get_line_item_detailed_report (self ):
45+ # Tests getting a line item detailed report.
4346 with open ('./tests/test_files/get_line_item_detailed_report.json' , 'r' ) as line_item_detailed_report_file :
4447 line_item_detailed_report_json = json .load (line_item_detailed_report_file )
4548 responses .add (
@@ -53,7 +56,7 @@ def test_get_line_item_detailed_report(self):
5356
5457 @responses .activate
5558 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 .
5760 with open ('./tests/test_files/create_line_item.json' , 'r' ) as new_lineitem_file :
5861 new_lineitem_data = json .load (new_lineitem_file )
5962 # Success response
@@ -76,9 +79,36 @@ def test_add_line_item(self):
7679 self .api .add_line_item (24 , new_lineitem_data )
7780 self .assertEqual (len (responses .calls ), 2 )
7881
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+
79109 @responses .activate
80110 def test_launch_line_item (self ):
81- # Tests closing a project .
111+ # Tests launching a line item .
82112 responses .add (
83113 responses .POST ,
84114 '{}/sample/v1/projects/24/lineItems/180/launch' .format (BASE_HOST ),
@@ -131,6 +161,7 @@ def test_pause_line_item(self):
131161
132162 @responses .activate
133163 def test_update_line_item (self ):
164+ # Tests updating a line item.
134165 with open ('./tests/test_files/update_line_item.json' , 'r' ) as new_lineitem_file :
135166 update_lineitem_data = json .load (new_lineitem_file )
136167
0 commit comments