def _get_ref(self): """Returns full url to this object (as in $ref)""" pid_value = self.get('control_number') pid_type = get_pid_type_from_schema(self.get('$schema')) endpoint = get_endpoint_from_pid_type(pid_type) return absolute_url(u'/api/{endpoint}/{control_number}'.format( endpoint=endpoint, control_number=pid_value))
def _get_ref(self): """Returns full url to this object (as in $ref)""" pid_value = self.get('control_number') pid_type = get_pid_type_from_schema(self.get('$schema')) endpoint = get_endpoint_from_pid_type(pid_type) return absolute_url(u'/api/{endpoint}/{control_number}'.format(endpoint=endpoint, control_number=pid_value))
def test_absolute_url_with_https_preferred_scheme(): config = {'PREFERRED_URL_SCHEME': 'https'} with patch.dict(current_app.config, config): expected = 'https://localhost:5000/foo' result = absolute_url('foo') assert expected == result
def test_absolute_url_with_https_server_name(): config = {'SERVER_NAME': 'https://example.com'} with patch.dict(current_app.config, config): expected = 'https://example.com/foo' result = absolute_url('foo') assert expected == result
def test_absolute_url_with_server_name_localhost(): config = {'SERVER_NAME': 'localhost:5000'} with patch.dict(current_app.config, config): expected = 'http://localhost:5000/foo' result = absolute_url('foo') assert expected == result
def test_absolute_url_with_undef_server_name(): config = {'SERVER_NAME': None} with patch.dict(current_app.config, config): expected = 'http://inspirehep.net/foo' result = absolute_url('foo') assert expected == result
def test_absolute_url_with_empty_server_name(): config = {} with patch.dict(current_app.config, config, clear=True): expected = 'http://inspirehep.net/foo' result = absolute_url('foo') assert expected == result