|
24 | 24 | # or submit itself to any jurisdiction.
|
25 | 25 | """Integration tests for record edit."""
|
26 | 26 |
|
| 27 | +from io import BytesIO |
| 28 | + |
27 | 29 |
|
28 | 30 | ###########################################
|
29 | 31 | # api/deposits/{pid}/actions/edit [POST]
|
@@ -130,3 +132,26 @@ def test_edit_record(client, create_deposit, users, auth_headers_for_superuser):
|
130 | 132 | .format(depid)
|
131 | 133 | }
|
132 | 134 | }
|
| 135 | + |
| 136 | + |
| 137 | +def test_edit_record_with_uploading_new_files(client, users, auth_headers_for_user, create_deposit): |
| 138 | + owner = users['cms_user'] |
| 139 | + deposit = create_deposit(owner, 'test-analysis-v0.0.1') |
| 140 | + deposit.files['file_1.txt'] = BytesIO(b'Hello world!') |
| 141 | + pid = deposit['_deposit']['id'] |
| 142 | + |
| 143 | + client.post('/deposits/{}/actions/publish'.format(pid), |
| 144 | + headers=auth_headers_for_user(owner)) |
| 145 | + |
| 146 | + client.post('/deposits/{}/actions/edit'.format(pid), |
| 147 | + headers=auth_headers_for_user(owner)) |
| 148 | + |
| 149 | + bucket = deposit.files.bucket |
| 150 | + client.put('/files/{}/file_2.txt'.format(bucket), |
| 151 | + input_stream=BytesIO(b'Hello brave new world!'), |
| 152 | + headers=auth_headers_for_user(owner)) |
| 153 | + |
| 154 | + resp = client.post('/deposits/{}/actions/publish'.format(pid), |
| 155 | + headers=auth_headers_for_user(owner)) |
| 156 | + |
| 157 | + assert len(resp.json['files']) == 2 |
0 commit comments