示例#1
0
def import_data(function_complete):
    data = [osmobj('N', id=1, lat=28.0, lon=-23.3)]
    fn = create_osm_file(data)

    c = CountingHandler()
    try:
        c.apply_file(fn)
    finally:
        os.remove(fn)

    function_complete.set()
示例#2
0
def import_data(function_complete):
    data = [osmobj('N', id=1, lat=28.0, lon=-23.3)]
    fn = create_osm_file(data)

    c = CountingHandler()
    try:
        c.apply_file(fn)
    finally:
        os.remove(fn)

    function_complete.set()
示例#3
0
def test_apply_diffs_with_simplify(mock):
    mock.set_script(("""\
        sequenceNumber=100
        timestamp=2017-08-26T11\\:04\\:02Z
    """, """
        n1 v23
        n1 v24
        w1
        r1
    """))
    svr = rserv.ReplicationServer("https://test.io", "opl")

    h = CountingHandler()
    assert 100 == svr.apply_diffs(h, 100, 10000, simplify=True)
    assert [1, 1, 1, 0] == h.counts
示例#4
0
def test_apply_diffs_count(mock):
    mock.set_script(("""\
        sequenceNumber=100
        timestamp=2017-08-26T11\\:04\\:02Z
    """, """
        n1
        w1
        r1
    """))
    svr = rserv.ReplicationServer("https://test.io", "opl")

    h = CountingHandler()
    assert 100 == svr.apply_diffs(h, 100, 10000)

    assert h.counts == [1, 1, 1, 0]
示例#5
0
def test_apply_diffs_without_simplify(mock):
    mock.set_script(("""\
        sequenceNumber=100
        timestamp=2017-08-26T11\:04\:02Z
    """, """
        n1 v23
        n1 v24
        w1
        r1
    """))
    svr = rserv.ReplicationServer("http://test.io", "opl")

    h = CountingHandler()
    assert_equals(100, svr.apply_diffs(h, 100, 10000, simplify=False))
    assert_equals([2, 1, 1, 0], h.counts)
示例#6
0
def test_threaded_processing():
    """ Process a file in a different thread and make sure that processing
        completes.
    """
    function_complete = threading.Event()
    c = CountingHandler()

    def import_data():
        c.apply_buffer('n1 x67.8 y-45.6932'.encode('utf-8'), 'opl')
        function_complete.set()

    t = threading.Thread(target=import_data)
    t.start()
    function_complete.wait(timeout=2)

    assert function_complete.is_set()
    assert c.counts == [1, 0, 0 ,0]
示例#7
0
def test_apply_reader_with_simplify(mock):
    mock.set_script(("""\
        sequenceNumber=100
        timestamp=2017-08-26T11\:04\:02Z
    """, """
        n1 v23
        n1 v24
        w1
        r1
    """))
    svr = rserv.ReplicationServer("http://test.io", "opl")

    h = CountingHandler()
    diffs = svr.collect_diffs(100, 100000)
    assert_is_not_none(diffs)

    diffs.reader.apply(h, simplify=True)
    assert_equals([1, 1, 1, 0], h.counts)
示例#8
0
def test_apply_reader_without_simplify(mock):
    mock.set_script(("""\
        sequenceNumber=100
        timestamp=2017-08-26T11\\:04\\:02Z
    """, """
        n1 v23
        n1 v24
        w1
        r1
    """))
    svr = rserv.ReplicationServer("https://test.io", "opl")

    h = CountingHandler()

    diffs = svr.collect_diffs(100, 100000)
    assert diffs is not None

    diffs.reader.apply(h, simplify=False)
    assert [2, 1, 1, 0] == h.counts