def test_processor_get_legend_entries(): theme1 = ThemeRecord(u'TEST', {'de': 'Theme 1'}) theme2 = ThemeRecord(u'TEST', {'de': 'Theme 2'}) office = OfficeRecord({'de': 'Test Office'}) law_status = LawStatusRecord.from_config(u'inForce') geometries = [ GeometryRecord(law_status, datetime.date.today(), Point(1, 1)) ] legend1 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend1'}, 'CodeA', 'bla', theme1, view_service_id=1) legend2 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend2'}, 'CodeB', 'bla', theme1, view_service_id=1) legend3 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend3'}, 'CodeC', 'bla', theme2, view_service_id=1) legend4 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend4'}, 'CodeD', 'bla', theme2, view_service_id=1) view_service1 = ViewServiceRecord( 'http://www.test1.url.ch', 1, 1.0, legend_at_web={'de': 'http://www.test1.url.ch'}, legends=[legend1, legend2]) view_service2 = ViewServiceRecord( 'http://www.test2.url.ch', 1, 1.0, legend_at_web={'de': 'http://www.test2.url.ch'}, legends=[legend3, legend4]) image = ImageRecord('1'.encode('utf-8')) plr1 = PlrRecord( theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service1, geometries, type_code='CodeA', ) plr2 = PlrRecord(theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service1, geometries, type_code='CodeB') plr3 = PlrRecord(theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service2, geometries, type_code='CodeB') plr4 = PlrRecord(theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service2, geometries, type_code='CodeB') inside_plrs = [plr1] outside_plrs = [plr2, plr3] after_process = Processor.get_legend_entries(inside_plrs, outside_plrs) assert len(inside_plrs) == len(after_process) inside_plrs = [plr3] outside_plrs = [plr4] after_process = Processor.get_legend_entries(inside_plrs, outside_plrs) assert len(after_process) == 1
def test_processor_get_legend_entries(law_status): theme1 = ThemeRecord(u'TEST', {'de': 'Theme 1'}) theme2 = ThemeRecord(u'TEST', {'de': 'Theme 2'}) office = OfficeRecord({'de': 'Test Office'}) geometries = [ GeometryRecord(law_status, datetime.date.today(), Point(1, 1)) ] legend1 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend1'}, u'type1', u'bla', theme1) legend2 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend2'}, u'type2', u'bla', theme1) legend3 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend3'}, u'type3', u'bla', theme2) legend4 = LegendEntryRecord(ImageRecord('1'.encode('utf-8')), {'de': 'legend4'}, u'type4', u'bla', theme2) view_service1 = ViewServiceRecord('http://www.test1.url.ch', 'http://www.test1.url.ch', legends=[legend1, legend2]) view_service2 = ViewServiceRecord('http://www.test2.url.ch', 'http://www.test2.url.ch', legends=[legend3, legend4]) image = ImageRecord('1'.encode('utf-8')) plr1 = PlrRecord( theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service1, geometries, type_code=u'type1', ) plr2 = PlrRecord(theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service1, geometries, type_code=u'type2') plr3 = PlrRecord(theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service2, geometries, type_code=u'type2') plr4 = PlrRecord(theme1, {'de': 'CONTENT'}, law_status, datetime.datetime.now(), office, image, view_service2, geometries, type_code=u'type2') inside_plrs = [plr1] outside_plrs = [plr2, plr3] after_process = Processor.get_legend_entries(inside_plrs, outside_plrs) assert len(inside_plrs) == len(after_process) inside_plrs = [plr3] outside_plrs = [plr4] after_process = Processor.get_legend_entries(inside_plrs, outside_plrs) assert len(after_process) == 1