# Path: bingmaps/urls/locations_build_urls.py
# class LocationByPointSchema(Location, Schema):
#     """Inherits from :class:`Location`
# 
#     Schema for query parameters in which all the fields will be in a ordered
#     way. All the fields will be dumped in the same order as mentioned in the
#     schema.
# 
#     Data Fields for the schema (taken from
#     https://msdn.microsoft.com/en-us/library/ff701710.aspx):
# 
#     :ivar point[Required]: A point on the Earth specified by a latitude and
#         longitude.
#     :ivar includeEntityTypes[Optional]: A comma separated list of entity types
#         selected from the following options:
#           - Address
#           - Neighborhood
#           - PopulatedPlace
#           - Postcode1
#           - AdminDivision1
#           - AdminDivision2
#           - CountryRegion
#         These entity types are ordered from the most specific entity to the
#         least specific entity. When entities of more than one entity type are
#         found, only the most specific entity is returned. For example, if you
#         specify Address and AdminDistrict1 as entity types and entities were
#         found for both types, only the Address entity information is returned
#         in the response. One exception to this rule is when both
#         PopulatedPlace and Neighborhood entity types are specified and
#         information is found for both. In this case, the information for both
#         entity types is returned. Also, more than one Neighborhood may be
#         returned because the area covered by two different neighborhoods can
#         overlap.
#     :ivar includeNeighborhood[Optional]: One of the following
#         values:
#           - 1: Include neighborhood information when available.
#           - 0 [default]: Do not include neighborhood information.
#     :ivar include[Optional]: The only value for this parameter is ciso2. When
#         you specify include=ciso2, the two-letter ISO country code is included
#         for addresses in the response.
#     :ivar c[Optional]: A string specifying the culture parameter
#     :ivar o[Optional]: A string for specifying the format of output(response)
#         Ex. - xml/json
#           - If empty, default output would be a JSON data string
#           - If given xml, the output would be an xml data string
#     :ivar maxResults[Optional]: An integer between 1 and 20 (number of
#         results)
#           - default=20
#     :ivar key[Required]: Bing maps api
#         key
#           - Required
# 
#     Post-Dump:
#         After dumping the data, build_query_string builds up the
#         queryParameters string. The final value after dumping the data would
#         be a string. The string would be similar to the one mentioned in the
#         below example.
# 
#     Example:
# 
#         ::
# 
#             >>> data = { 'point': '47.64054,-122.12934',
#             ...          'includeEntityTypes': 'Address',
#             ...          'c': 'te',
#             ...          'o': 'xml',
#             ...          'includeNeighborhood': 1,
#             ...          'key': 'abs'
#             ...         }
#             >>> query = LocationByPointSchema()
#             >>> query.dump(data).data
#             OrderedDict([('version', 'v1'), ('restApi', 'Locations'), ('query\
# ', '47.64054,-122.12934?includeEntityTypes=Address&\
# includeNeighborhood=1&include=ciso2&c=te&o=xml&maxResults=20&key=abs')])
# 
# 
#         In the output, you can see 'include', 'maxResults' in the string
#         although we haven't specified any values because they are default
#         values specified in the schema.
#     """
#     point = fields.Str(
#         required=True,
#         error_messages={'required': 'coordinates should be provided'}
#     )
#     includeEntityTypes = fields.Str()
#     includeNeighborhood = fields.Int(
#         default=0
#     )
#     include = fields.Str(
#         default='ciso2'
#     )
#     c = fields.Str()
#     o = fields.Str()
#     maxResults = fields.Int(
#         default=20
#     )
#     key = fields.Str(
#         required=True,
#         error_messages={'required': 'Please provide a key'}
#     )
# 
#     class Meta:
#         fields = ('version', 'restApi', 'resourcePath',
#                   'point', 'includeEntityTypes', 'includeNeighborhood',
#                   'include', 'c', 'o', 'maxResults', 'key')
#         ordered = True
# 
#     @post_dump
#     def build_query_string(self, data):
#         """This method occurs after dumping the data into the class.
# 
#         Args:
#             data (dict): dictionary of all the query values
# 
#         Returns:
#             data (dict): ordered dict of all the values
#         """
#         queryValues = []
#         keys_to_be_removed = []
#         for key, value in data.items():
#             if key not in ['version', 'restApi', 'resourcePath']:
#                 if not key == 'point':
#                     queryValues.append('{0}={1}'.format(key, value))
#                     keys_to_be_removed.append(key)
#                 keys_to_be_removed.append(key)
#         queryString = '&'.join(queryValues)
#         data['query'] = '{0}?{1}'.format(data['point'], queryString)
#         for k in list(set(keys_to_be_removed)):
#             del data[k]
#         return data
# 
# Path: tests/fixtures.py
# BING_MAPS_KEY = 'Av6_H8GIYQyP-DLQwLOKDknW64Qfm' \
#                 'VgJmVpfiSO861v0x_j1pLPCOW6s-70nCzEW'
# def create_tmp_dir(tmpdir):


from bingmaps.urls import LocationByPointSchema
from .fixtures import parametrize, BING_MAPS_KEY


DATA = [
    {'point': '1,2',
     'includeEntityTypes': 'address',
     'key': BING_MAPS_KEY
     },
    {'point': '2,3',
     'includeEntityTypes': 'address',
     },
    {
        'point': '1,2',
        'includeEntityTypes': 'address',

# Path: bingmaps/urls/locations_build_urls.py
# class LocationByPointSchema(Location, Schema):
#     """Inherits from :class:`Location`
# 
#     Schema for query parameters in which all the fields will be in a ordered
#     way. All the fields will be dumped in the same order as mentioned in the
#     schema.
# 
#     Data Fields for the schema (taken from
#     https://msdn.microsoft.com/en-us/library/ff701710.aspx):
# 
#     :ivar point[Required]: A point on the Earth specified by a latitude and
#         longitude.
#     :ivar includeEntityTypes[Optional]: A comma separated list of entity types
#         selected from the following options:
#           - Address
#           - Neighborhood
#           - PopulatedPlace
#           - Postcode1
#           - AdminDivision1
#           - AdminDivision2
#           - CountryRegion
#         These entity types are ordered from the most specific entity to the
#         least specific entity. When entities of more than one entity type are
#         found, only the most specific entity is returned. For example, if you
#         specify Address and AdminDistrict1 as entity types and entities were
#         found for both types, only the Address entity information is returned
#         in the response. One exception to this rule is when both
#         PopulatedPlace and Neighborhood entity types are specified and
#         information is found for both. In this case, the information for both
#         entity types is returned. Also, more than one Neighborhood may be
#         returned because the area covered by two different neighborhoods can
#         overlap.
#     :ivar includeNeighborhood[Optional]: One of the following
#         values:
#           - 1: Include neighborhood information when available.
#           - 0 [default]: Do not include neighborhood information.
#     :ivar include[Optional]: The only value for this parameter is ciso2. When
#         you specify include=ciso2, the two-letter ISO country code is included
#         for addresses in the response.
#     :ivar c[Optional]: A string specifying the culture parameter
#     :ivar o[Optional]: A string for specifying the format of output(response)
#         Ex. - xml/json
#           - If empty, default output would be a JSON data string
#           - If given xml, the output would be an xml data string
#     :ivar maxResults[Optional]: An integer between 1 and 20 (number of
#         results)
#           - default=20
#     :ivar key[Required]: Bing maps api
#         key
#           - Required
# 
#     Post-Dump:
#         After dumping the data, build_query_string builds up the
#         queryParameters string. The final value after dumping the data would
#         be a string. The string would be similar to the one mentioned in the
#         below example.
# 
#     Example:
# 
#         ::
# 
#             >>> data = { 'point': '47.64054,-122.12934',
#             ...          'includeEntityTypes': 'Address',
#             ...          'c': 'te',
#             ...          'o': 'xml',
#             ...          'includeNeighborhood': 1,
#             ...          'key': 'abs'
#             ...         }
#             >>> query = LocationByPointSchema()
#             >>> query.dump(data).data
#             OrderedDict([('version', 'v1'), ('restApi', 'Locations'), ('query\
# ', '47.64054,-122.12934?includeEntityTypes=Address&\
# includeNeighborhood=1&include=ciso2&c=te&o=xml&maxResults=20&key=abs')])
# 
# 
#         In the output, you can see 'include', 'maxResults' in the string
#         although we haven't specified any values because they are default
#         values specified in the schema.
#     """
#     point = fields.Str(
#         required=True,
#         error_messages={'required': 'coordinates should be provided'}
#     )
#     includeEntityTypes = fields.Str()
#     includeNeighborhood = fields.Int(
#         default=0
#     )
#     include = fields.Str(
#         default='ciso2'
#     )
#     c = fields.Str()
#     o = fields.Str()
#     maxResults = fields.Int(
#         default=20
#     )
#     key = fields.Str(
#         required=True,
#         error_messages={'required': 'Please provide a key'}
#     )
# 
#     class Meta:
#         fields = ('version', 'restApi', 'resourcePath',
#                   'point', 'includeEntityTypes', 'includeNeighborhood',
#                   'include', 'c', 'o', 'maxResults', 'key')
#         ordered = True
# 
#     @post_dump
#     def build_query_string(self, data):
#         """This method occurs after dumping the data into the class.
# 
#         Args:
#             data (dict): dictionary of all the query values
# 
#         Returns:
#             data (dict): ordered dict of all the values
#         """
#         queryValues = []
#         keys_to_be_removed = []
#         for key, value in data.items():
#             if key not in ['version', 'restApi', 'resourcePath']:
#                 if not key == 'point':
#                     queryValues.append('{0}={1}'.format(key, value))
#                     keys_to_be_removed.append(key)
#                 keys_to_be_removed.append(key)
#         queryString = '&'.join(queryValues)
#         data['query'] = '{0}?{1}'.format(data['point'], queryString)
#         for k in list(set(keys_to_be_removed)):
#             del data[k]
#         return data
# 
# Path: tests/fixtures.py
# BING_MAPS_KEY = 'Av6_H8GIYQyP-DLQwLOKDknW64Qfm' \
#                 'VgJmVpfiSO861v0x_j1pLPCOW6s-70nCzEW'
# def create_tmp_dir(tmpdir):


# Path: tests/test_location_by_point_query_string.py
from bingmaps.urls import LocationByPointSchema
from .fixtures import parametrize, BING_MAPS_KEY



DATA = [
    {'point': '1,2',
     'includeEntityTypes': 'address',
     'key': BING_MAPS_KEY
     },
    {'point': '2,3',
     'includeEntityTypes': 'address',
     },
    {
        'point': '1,2',
        'includeEntityTypes': 'address',

        'key': BING_MAPS_KEY