Exemple #1
0
def test_download_dastcom5_creates_folder(
    mock_isdir, mock_zipfile, mock_makedirs, mock_request
):
    mock_isdir.return_value = False
    mock_zipfile.is_zipfile.return_value = False
    dastcom5.download_dastcom5()
    mock_makedirs.assert_called_once_with(dastcom5.POLIASTRO_LOCAL_PATH)
Exemple #2
0
def test_download_dastcom5_downloads_file(mock_request, mock_isdir, mock_zipfile):
    mock_isdir.side_effect = lambda x: x == dastcom5.POLIASTRO_LOCAL_PATH
    mock_zipfile.is_zipfile.return_value = False
    dastcom5.download_dastcom5()
    mock_request.assert_called_once_with(dastcom5.FTP_DB_URL + 'dastcom5.zip',
                                         os.path.join(dastcom5.POLIASTRO_LOCAL_PATH, 'dastcom5.zip'),
                                         dastcom5._show_download_progress)
Exemple #3
0
def test_download_dastcom5_downloads_file(mock_request, mock_isdir,
                                          mock_zipfile):
    mock_isdir.side_effect = lambda x: x == dastcom5.POLIASTRO_LOCAL_PATH
    mock_zipfile.is_zipfile.return_value = False
    dastcom5.download_dastcom5()
    mock_request.assert_called_once_with(
        dastcom5.FTP_DB_URL + "dastcom5.zip",
        os.path.join(dastcom5.POLIASTRO_LOCAL_PATH, "dastcom5.zip"),
        dastcom5._show_download_progress,
    )
Exemple #4
0
def test_download_dastcom5_raises_error_when_folder_exists(
    mock_request, mock_isdir, mock_zipfile, mock_makedirs
):
    mock_isdir.side_effect = lambda x: x == os.path.join(
        dastcom5.POLIASTRO_LOCAL_PATH, "dastcom5"
    )
    with pytest.raises(FileExistsError):
        dastcom5.download_dastcom5()
    mock_isdir.assert_called_once_with(
        os.path.join(dastcom5.POLIASTRO_LOCAL_PATH, "dastcom5")
    )
Exemple #5
0
def main():
    parser = argparse.ArgumentParser(
        prog="poliastro",
        description="Command line tools for the poliastro Python library.")
    parser.add_argument("--version", action='version',
                        version=poliastro.__version__)
    parser.add_argument("--download-dastcom5", action="store_true",
                        help="Downloads DASTCOM5 database")

    args = parser.parse_args()

    if args.download_dastcom5:
        download_dastcom5()
    else:
        parser.print_help()
Exemple #6
0
def main():
    parser = argparse.ArgumentParser(
        prog="poliastro",
        description="Command line tools for the poliastro Python library.")
    parser.add_argument("--version",
                        action='version',
                        version=poliastro.__version__)
    parser.add_argument("--download-dastcom5",
                        action="store_true",
                        help="Downloads DASTCOM5 database")

    args = parser.parse_args()

    if args.download_dastcom5:
        download_dastcom5()
    else:
        parser.print_help()
Exemple #7
0
def test_download_dastcom5_creates_folder(mock_isdir, mock_zipfile,
                                          mock_makedirs, mock_request):
    mock_isdir.return_value = False
    mock_zipfile.is_zipfile.return_value = False
    dastcom5.download_dastcom5()
    mock_makedirs.assert_called_once_with(dastcom5.POLIASTRO_LOCAL_PATH)