Пример #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_tile_img_pil_serial_exists(capsys):
    """Test convert.tile_img skips tiling"""
    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_PIL

    os.mkdir(os.path.join(out_dir, "test_tiling_image"))

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

    captured = capsys.readouterr()
    helpers.tear_down()
    helpers.enable_tqdm()

    assert "test_tiling_image.jpg already tiled. Skipping tiling." in captured.out
Пример #3
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
Пример #4
0
def test_dir_to_map_fails_no_files():
    """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)

    with pytest.raises(ValueError):
        convert.dir_to_map(in_dir,
                           out_dir=out_dir,
                           cat_wcs_fits_file=with_path("test_image.fits"))

    helpers.tear_down()
    helpers.enable_tqdm()
Пример #5
0
def test_files_to_map_fails_file_not_found():
    """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")

    files = [
        with_path("test_tiling_image.jpg"),
        with_path("test_catalog_radec.cat"),
        with_path("does_not_exist.txt"),
    ]

    with pytest.raises(FileNotFoundError):
        convert.files_to_map(files,
                             out_dir=out_dir,
                             cat_wcs_fits_file=with_path("test_image.fits"))

    helpers.tear_down()
    helpers.enable_tqdm()