def get_logo_config(): """ Returns a dictionary of the configured file path's to the logos. Returns: dict: The configured paths to the logos wrapped in a dictionary. """ assert Config._config is not None confederation_key = 'confederation' oereb_key = 'oereb' canton_key = 'canton' msg = 'The definition for "{key}" must be set. Got: {found_config}' logo_dict = Config._config.get('logo') if not logo_dict.get(confederation_key): raise ConfigurationError( msg.format(key=confederation_key, found_config=logo_dict)) if not logo_dict.get(oereb_key): raise ConfigurationError( msg.format(key=oereb_key, found_config=logo_dict)) if not logo_dict.get(canton_key): raise ConfigurationError( msg.format(key=canton_key, found_config=logo_dict)) file_adapter = FileAdapter() confederation_logo = ImageRecord( file_adapter.read(logo_dict.get(confederation_key))) oereb_logo = ImageRecord(file_adapter.read(logo_dict.get(oereb_key))) canton_logo = ImageRecord(file_adapter.read(logo_dict.get(canton_key))) return { confederation_key: confederation_logo, oereb_key: oereb_logo, canton_key: canton_logo }
def _get_test_extract(glossary): date = datetime.datetime.now() file_adapter = FileAdapter() with pyramid_oereb_test_config(): view_service = ViewServiceRecord(u'http://geowms.bl.ch', 1, 1.0, {'de': u'http://geowms.bl.ch'}, None) real_estate = RealEstateRecord( u'RealEstate', u'BL', u'Liestal', 2829, 11395, MultiPolygon([Polygon([(0, 0), (1, 1), (1, 0)])]), u'http://www.geocat.ch', u'1000', u'BL0200002829', u'CH775979211712') real_estate.set_view_service(view_service) real_estate.set_main_page_view_service(view_service) office_record = OfficeRecord({'de': u'AGI'}) resolver = DottedNameResolver() date_method_string = Config.get('extract').get('base_data').get( 'methods').get('date') date_method = resolver.resolve(date_method_string) av_update_date = date_method(real_estate) base_data = Config.get_base_data(av_update_date) av_provider_method_string = Config.get('extract').get('base_data').get( 'methods').get('provider') av_provider_method = resolver.resolve(av_provider_method_string) cadaster_state = date theme = ThemeRecord(u'TEST', {'de': u'TEST TEXT'}) datasources = [DatasourceRecord(theme, date, office_record)] plr_cadastre_authority = Config.get_plr_cadastre_authority() embeddable = EmbeddableRecord(cadaster_state, plr_cadastre_authority, av_provider_method(real_estate), av_update_date, datasources) extract = ExtractRecord( real_estate, ImageRecord(file_adapter.read('tests/resources/python.svg')), ImageRecord(file_adapter.read('tests/resources/python.svg')), ImageRecord(file_adapter.read('tests/resources/python.svg')), ImageRecord(file_adapter.read('tests/resources/python.svg')), office_record, base_data, embeddable, exclusions_of_liability=[ ExclusionOfLiabilityRecord({'de': u'Haftungsausschluss'}, {'de': u'Test'}) ], glossaries=glossary, general_information={'de': u'Allgemeine Informationen'}, certification={'de': u'certification'}, certification_at_web={'de': u'certification_at_web'}, ) # extract.qr_code = 'VGhpcyBpcyBub3QgYSBRUiBjb2Rl'.encode('utf-8') TODO: # qr_code Must be an image ('base64Binary'), but even with images xml validation # fails on it. # extract.electronic_signature = 'Signature' # TODO: fix signature rendering first return extract
def test_read_no_file(): base_path = os.path.abspath('./tests/resources') file_adapter = FileAdapter(base_path) with pytest.raises(IOError) as exc_info: file_adapter.read('plr119') assert 'Not a file:' in str(exc_info.value)
def test_read(): base_path = os.path.abspath('./tests/resources') file_adapter = FileAdapter(base_path) content = file_adapter.read('file_adapter_dummy.txt').decode('utf-8') assert content.startswith( 'If the content looks like this, the test has been successful.')