예제 #1
0
 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))
예제 #2
0
 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))
예제 #3
0
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
예제 #4
0
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
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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