예제 #1
0
def test__draw_js():
    b = Builder(map_json='"useless_map"', model_json='"useless_model"',
                embedded_css='')

    def look_for_string(st, substring):
        """Look for the string in the substring. This solves a bug in py.test
        for these cases"""
        try:
            found = st.find(substring)
            assert found > -1
        except AssertionError:
            raise AssertionError('Could not find\n\n%s\n\nin\n\n%s' % (substring, st))

    # no static parse, dev
    ijs = b._initialize_javascript('id', 'local')
    js = b._draw_js('id', True, 'all', True, True, True, 'pan', True, None)
    look_for_string(ijs, 'var map_data_id = "useless_map";')
    look_for_string(ijs, 'var model_data_id = "useless_model";')
    look_for_string(js, 'Builder(map_data_id, model_data_id, embedded_css_id, d3.select("#id"), options);')

    # static parse, not dev
    ijs = b._initialize_javascript('id', 'local')
    static_index = '{"my": ["useless", "index"]}'
    js = b._draw_js('id', True, 'all', True, False, True, 'pan', True, static_index)
    look_for_string(ijs, 'var map_data_id = "useless_map";')
    look_for_string(ijs, 'var model_data_id = "useless_model";')
    look_for_string(js, 'escher.static.load_map_model_from_url("{0}/{1}/maps/", "{0}/{1}/models/",'.format(__schema_version__, __map_model_version__))
    look_for_string(js, static_index)
    look_for_string(js, 'options, function(map_data_id, model_data_id, options) {')
    look_for_string(js, 'escher.Builder(map_data_id, model_data_id, embedded_css_id, d3.select("#id"), options);')
예제 #2
0
def test__draw_js():
    b = Builder(map_json='"useless_map"', model_json='"useless_model"',
                embedded_css='')

    def look_for_string(st, substring):
        """Look for the string in the substring. This solves a bug in py.test
        for these cases"""
        try:
            found = st.find(substring)
            assert found > -1
        except AssertionError:
            raise AssertionError('Could not find\n\n%s\n\nin\n\n%s' % (substring, st))

    # no static parse, dev
    ijs = b._initialize_javascript('id', 'local')
    js = b._draw_js('id', True, 'all', True, True, True, 'pan', True, None)
    look_for_string(ijs, 'var map_data_id = "useless_map";')
    look_for_string(ijs, 'var model_data_id = "useless_model";')
    look_for_string(js, 'Builder(map_data_id, model_data_id, embedded_css_id, d3.select("#id"), options);')

    # static parse, not dev 
    ijs = b._initialize_javascript('id', 'local')
    static_index = '{"my": ["useless", "index"]}'
    js = b._draw_js('id', True, 'all', True, False, True, 'pan', True, static_index)
    look_for_string(ijs, 'var map_data_id = "useless_map";')
    look_for_string(ijs, 'var model_data_id = "useless_model";')
    look_for_string(js, 'escher.static.load_map_model_from_url("%s/maps/", "%s/models/",' % (__schema_version__, __schema_version__))
    look_for_string(js, static_index)
    look_for_string(js, 'options, function(map_data_id, model_data_id, options) {')
    look_for_string(js, 'escher.Builder(map_data_id, model_data_id, embedded_css_id, d3.select("#id"), options);')