Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_placeInfo4_ne():
# test __ne__
from osxphotos.placeinfo import PlaceInfo4
place1 = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
place2 = PlaceInfo4(PLACE_4_INFO_2, PLACE_4_COUNTRY_2)
assert place1 != place2
def test_placeInfo4_ne3():
# test __ne__ unlike objects
from osxphotos.placeinfo import PlaceInfo4, PlaceInfo5
place1 = PlaceInfo4(PLACE_4_INFO_2, PLACE_4_COUNTRY_2)
place2 = PlaceInfo5(REVERSE_GEO_LOC_DATA_1)
assert place1 != place2
def test_placeInfo4_ne():
# test __ne__
from osxphotos.placeinfo import PlaceInfo4
place1 = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
place2 = PlaceInfo4(PLACE_4_INFO_2, PLACE_4_COUNTRY_2)
assert place1 != place2
def test_placeInfo4_ne2():
# test __ne__ unlike objects
from osxphotos.placeinfo import PlaceInfo4
place1 = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
place2 = "Foo"
assert place1 != place2
def test_placeInfo4_eq():
# test __eq__
from osxphotos.placeinfo import PlaceInfo4
place1 = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
place2 = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
assert place1 == place2
def test_placeInfo4():
# test valid place data info returns a PlaceInfo object
from osxphotos.placeinfo import PlaceInfo4, PlaceInfo
place = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
assert place is not None
assert isinstance(place, PlaceInfo)
assert place.name == "St James's Park, Westminster, United Kingdom"
assert place.names.city == ["Westminster"]
assert place.names.country == ["United Kingdom"]
assert place.names.area_of_interest == ["St James's Park"]
assert place.names.state_province == ["England"]
assert place.names.sub_administrative_area == ["London"]
assert place.names.region == []
assert place.country_code == "GB"
assert place.address_str is None
assert place.address.city is None
assert place.address.country is None
assert place.address.postal_code is None
assert place.address.state_province is None
assert place.address.street is None
def test_placeInfo4_eq():
# test __eq__
from osxphotos.placeinfo import PlaceInfo4
place1 = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
place2 = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
assert place1 == place2
def place(self):
""" Returns PlaceInfo object containing reverse geolocation info """
# implementation note: doesn't create the PlaceInfo object until requested
# then memoizes the object in self._place to avoid recreating the object
if self._db._db_version <= _PHOTOS_4_VERSION:
try:
return self._place # pylint: disable=access-member-before-definition
except AttributeError:
if self._info["placeNames"]:
self._place = PlaceInfo4(
self._info["placeNames"], self._info["countryCode"]
)
else:
self._place = None
return self._place
else:
try:
return self._place # pylint: disable=access-member-before-definition
except AttributeError:
if self._info["reverse_geolocation"]:
self._place = PlaceInfo5(self._info["reverse_geolocation"])
else:
self._place = None
return self._place