def test_preprintproviders_added_to_cors_whitelist(self): url = api_v2_url('users/me/') domain = urlparse("https://dinoprints.sexy") preprintprovider = factories.PreprintProviderFactory( domain=domain.geturl().lower(), _id="DinoXiv") settings.load_origins_whitelist() request = self.request_factory.get(url, HTTP_ORIGIN=domain.geturl()) response = HttpResponse() self.middleware.process_request(request) processed = self.middleware.process_response(request, response) assert_equal(response['Access-Control-Allow-Origin'], domain.geturl())
def set_preprint_providers(): """Populate `PreprintProvider` to test database for testing.""" providers = { 'osf': 'Open Science Framework', 'socarxiv': 'SocArXiv', 'engrxiv': 'EngrXiv', 'psyarxiv': 'PsyArXiv', } for key, value in providers.items(): provider = factories.PreprintProviderFactory() provider._id = key provider.name = value provider.save()
def test_success_batch_response(self, app, url): provider = factories.PreprintProviderFactory() provider.doi_prefix = '10.123yeah' provider.save() preprint_list = [ factories.PreprintFactory(set_doi=False, provider=provider) for _ in range(5) ] xml_response = self.build_batch_success_xml(preprint_list) context_data = self.make_mailgun_payload(xml_response) app.post(url, context_data) for preprint in preprint_list: assert preprint.get_identifier_value( 'doi') == settings.DOI_FORMAT.format( prefix=provider.doi_prefix, guid=preprint._id)