示例#1
0
def test_tile_img_mpl_parallel():
    """Test convert.tile_img"""
    helpers.disbale_tqdm()
    helpers.setup(with_data=True)

    out_dir = helpers.TEST_PATH
    test_image = os.path.join(out_dir, "test_tiling_image.jpg")
    pbar_loc = 0
    min_zoom = 0
    image_engine = convert.IMG_ENGINE_MPL

    convert.tile_img(
        test_image,
        pbar_loc,
        min_zoom=min_zoom,
        image_engine=image_engine,
        out_dir=out_dir,
        mp_procs=2,
    )

    expected_dir = os.path.join(out_dir, "expected_test_tiling_image_mpl")
    actual_dir = os.path.join(out_dir, "test_tiling_image")

    dirs_match = helpers.compare_file_directories(expected_dir, actual_dir)

    helpers.tear_down()
    helpers.enable_tqdm()

    assert dirs_match
示例#2
0
def test_dir_to_map():
    """Integration test for making files into map"""
    helpers.disbale_tqdm()
    helpers.setup(with_data=True)

    with_path = lambda f: os.path.join(helpers.TEST_PATH, f)
    out_dir = with_path("test_web")
    in_dir = with_path("test_web_in")
    if not os.path.exists(in_dir):
        os.mkdir(in_dir)

    files = [
        "test_tiling_image.jpg",
        "test_catalog_radec.cat",
    ]

    for f in files:
        shutil.copy(with_path(f), os.path.join(in_dir, f))

    expected_dir = with_path("expected_test_web")

    # inject current version in to test_index.html
    version = helpers.get_version()
    raw_path = os.path.join(expected_dir, "index.html")
    with open(raw_path, "r") as f:
        converted = list(
            map(lambda l: l.replace("VERSION", version), f.readlines()))

    with open(raw_path, "w") as f:
        f.writelines(converted)

    convert.dir_to_map(
        in_dir,
        out_dir=out_dir,
        catalog_delim=" ",
        cat_wcs_fits_file=with_path("test_image.fits"),
    )

    actual_dir = out_dir

    dirs_match = helpers.compare_file_directories(expected_dir, actual_dir)

    helpers.tear_down()
    helpers.enable_tqdm()

    assert dirs_match