|
3 | 3 | import urllib |
4 | 4 | from django.core.exceptions import MultipleObjectsReturned |
5 | 5 |
|
6 | | -from framework.auth import Auth |
7 | 6 | from osf.models import Guid, NodeLicenseRecord, OSFUser |
8 | 7 | from osf.modm_compat import Q |
9 | | -from osf_tests.factories import AuthUserFactory, UserFactory, NodeFactory, NodeLicenseRecordFactory, RegistrationFactory, PreprintFactory |
| 8 | +from osf_tests.factories import AuthUserFactory, UserFactory, NodeFactory, NodeLicenseRecordFactory, \ |
| 9 | + RegistrationFactory, PreprintFactory, PreprintProviderFactory |
10 | 10 | from tests.base import OsfTestCase |
11 | 11 | from tests.test_websitefiles import TestFile |
12 | 12 | from website.settings import MFR_SERVER_URL, WATERBUTLER_URL |
@@ -170,7 +170,7 @@ def test_resolve_guid_download_file(self): |
170 | 170 |
|
171 | 171 | res = self.app.get(pp.url + 'download') |
172 | 172 | assert res.status_code == 302 |
173 | | - assert '/v1/resources/{}/providers/{}{}?action=download&version=1&direct'.format(pp.node._id, pp.primary_file.provider, pp.primary_file.path) in res.location |
| 173 | + assert '{}/v1/resources/{}/providers/{}{}?action=download&version=1&direct'.format(WATERBUTLER_URL, pp.node._id, pp.primary_file.provider, pp.primary_file.path) in res.location |
174 | 174 |
|
175 | 175 | res = self.app.get(pp.url + 'download/') |
176 | 176 | assert res.status_code == 302 |
@@ -200,6 +200,26 @@ def test_resolve_guid_download_file(self): |
200 | 200 | assert res.status_code == 302 |
201 | 201 | assert '{}/v1/resources/{}/providers/{}{}?action=download&version=1&direct'.format(WATERBUTLER_URL, unpub_pp.node._id, unpub_pp.primary_file.provider, unpub_pp.primary_file.path) in res.location |
202 | 202 |
|
| 203 | + @mock.patch('website.settings.USE_EXTERNAL_EMBER', True) |
| 204 | + @mock.patch('website.settings.EXTERNAL_EMBER_APPS', { |
| 205 | + 'preprints': { |
| 206 | + 'url': '/preprints/', |
| 207 | + 'server': 'http://localhost:4200', |
| 208 | + 'path': '/preprints/' |
| 209 | + }, |
| 210 | + }) |
| 211 | + def test_resolve_guid_download_file_from_emberapp_preprints(self): |
| 212 | + provider = PreprintProviderFactory(name='Sockarxiv') |
| 213 | + pp = PreprintFactory(finish=True, provider=provider) |
| 214 | + |
| 215 | + res = self.app.get('/preprints/sockarxiv' + pp.url + 'download') |
| 216 | + assert res.status_code == 302 |
| 217 | + assert '{}/v1/resources/{}/providers/{}{}?action=download&version=1&direct'.format(WATERBUTLER_URL, pp.node._id, pp.primary_file.provider, pp.primary_file.path) in res.location |
| 218 | + |
| 219 | + res = self.app.get('/preprints/sockarxiv' + pp.url + 'download/') |
| 220 | + assert res.status_code == 302 |
| 221 | + assert '{}/v1/resources/{}/providers/{}{}?action=download&version=1&direct'.format(WATERBUTLER_URL, pp.node._id, pp.primary_file.provider, pp.primary_file.path) in res.location |
| 222 | + |
203 | 223 | def test_resolve_guid_download_file_export(self): |
204 | 224 | pp = PreprintFactory(finish=True) |
205 | 225 |
|
|
0 commit comments