Esempio n. 1
0
    def build_url(self, config, query):
        """
        Build the search url for the current provider using the config

        Raises:
            ValueError: should raise a error with api key

        Returns:
            [string]: full url for the request
        """
        current_provider = [
            provider for provider in config['providers']
            if provider['name'] == self.provider_name
        ][0]
        current_provider['query']['q'] = str(query)

        query_strings = helper.build_query_strings(current_provider['query'])

        return current_provider['base_url'] + query_strings
Esempio n. 2
0
    def build_url(self, config, query):
        """
        Build the search url for the current provider using the config

        Raises:
            ValueError: should raise a error with api key

        Returns:
            [string]: full url for the request
        """
        if(not os.environ['FLICKR_API_KEY']):
            raise ValueError('Environement variable "FLICKR_API_KEY" is empty')
        
        current_provider = [provider for provider in config['providers'] if provider['name'] == self.provider_name][0]
        current_provider['query']['text'] = str(query)
        current_provider['query']['api_key'] = os.environ['FLICKR_API_KEY']

        query_strings = helper.build_query_strings(current_provider['query'])

        return current_provider['base_url'] + query_strings
Esempio n. 3
0
def test_should_pass_fixtures(get_search_data):
    for search_data in get_search_data:
        actual_result = helper.build_query_strings(search_data[0])
        assert actual_result == search_data[1]
Esempio n. 4
0
def test_should_pass_parametrize(query, expected):
    actual_result = helper.build_query_strings(query)
    assert actual_result == expected