예제 #1
0
def test_building_tree_where_no_links_repeat(tmpdir):
    path_json = os.path.abspath(
        os.path.join(
            os.path.dirname(__file__),
            'test_data/road_pricing/osm_to_network_ids_no_link_repeat.json'))
    path_csv = os.path.abspath(
        os.path.join(
            os.path.dirname(__file__),
            'test_data/road_pricing/osm_tolls_with_network_ids_no_link_overlap.csv'
        ))
    xml_tree_root = road_pricing.build_tree_from_csv_json(
        path_csv,
        path_json,
        toll_type='cordon',
        toll_scheme_name='cordon-toll',
        toll_description='A simple cordon toll scheme')
    road_pricing.write_xml(xml_tree_root, tmpdir)

    expected_xml = os.path.abspath(
        os.path.join(
            os.path.dirname(__file__),
            'test_data/road_pricing/roadpricing-file_no_link_repeat.xml'))
    expected_xml_obj = lxml.etree.parse(expected_xml)
    generated_xml_obj = lxml.etree.parse(
        os.path.join(tmpdir, 'roadpricing-file.xml'))
    assert_xml_trees_equal(generated_xml_obj, expected_xml_obj)
예제 #2
0
def test_writes_road_pricing_xml_file_with_expected_content(
        tmpdir, road_pricing_sample_xml):
    road_pricing.write_xml(road_pricing_sample_xml.getroot(), tmpdir)

    expected_xml = os.path.join(tmpdir, 'roadpricing-file.xml')
    assert os.path.exists(expected_xml)

    xml_obj = lxml.etree.parse(expected_xml)
    assert_xml_trees_equal(road_pricing_sample_xml, xml_obj)
예제 #3
0
def test_writes_well_formed_and_valid_road_pricing_xml_file(
        tmpdir, road_pricing_dtd, road_pricing_sample_xml):
    road_pricing.write_xml(road_pricing_sample_xml.getroot(), tmpdir)

    expected_xml = os.path.join(tmpdir, 'roadpricing-file.xml')
    assert os.path.exists(expected_xml)
    xml_obj = lxml.etree.parse(expected_xml)
    assert road_pricing_dtd.validate(xml_obj), \
        'Doc generated at {} is not valid against DTD due to {}'.format(expected_xml,
                                                                        road_pricing_dtd.error_log.filter_from_errors())