def testAttributeAssignment(self): """Tests if Map.__setattr__() works as expected.""" coords = types.Map() coords.x = 0 coords.y = 1 assert coords.x == 0 and coords.y == 1
def testAttributeDeletion(self): """Tests if Map.__delattr__() works as expected.""" coords = types.Map(x=0, y=1) del coords.x with pytest.raises(AttributeError): coords.x
def testAttributeAccess(self): """Tests if Map.__getattr__() works as expected.""" coords = types.Map(x=0, y=1) assert coords.x == 0 and coords.y == 1 with pytest.raises(AttributeError): coords.z
def __init__(self, data: dict): """ Creates a new instance. Args: data: The API JSON response """ super().__init__([ types.Map(id=_id, name=name) for (_id, name) in zip(data['Codigos'], data['Nomes']) ])
def locales(cls) -> types.Map: """ Returns the available localizations. Returns: The available localizations mapping """ return types.Map({ locale: Localization(locale, locale_file) for locale, locale_file in map( lambda locale_file: (locale_file.basename, locale_file), io.Directory(io.Path.PKG_TRANSLATION_DIR).files( pattern='*.yaml')) })
def __init__(self, locale: str, locale_file: io.File): """ Creates a new localization instance. Args: locale: The localization name locale_file: The localization file Raises: geodatabr.core.i18n.UnsupportedLocaleFileError: Raised when a localization file is invalid """ self._locale = locale try: self._translations = types.Map(yaml.load(locale_file.read())) except Exception: raise UnsupportedLocaleFileError('Unsupported localization file')
def testCopy(self): """Tests if Map.copy() works as expected.""" coords = types.Map(x=0, y=1) assert isinstance(coords.copy(), types.Map) assert coords.copy() == coords
def testStringRepresentation(self): """Tests if Map.__repr__() works as expected.""" coords = types.Map(x=0, y=1) assert repr(coords) == 'Map(x=0, y=1)'