コード例 #1
0
ファイル: test_auth.py プロジェクト: arundurvasula/onecodex
def test_auth_invalid_key_format():
    parser = OneCodexArgParser()
    input_args = ["upload", "my_file.fasta",
                  "--api-key",
                  "my_api_key_is_too_short"]
    args = parser.parse_args(input_args)
    OneCodexAuth(args, check_for_update=False, creds_file=TEST_CREDS)
コード例 #2
0
ファイル: cli_tests.py プロジェクト: arundurvasula/onecodex
def test_cli_upload():
    parser = OneCodexArgParser()
    input_args = ["upload", "my_file.fasta", "--no-threads"]
    args = parser.parse_args(input_args)
    assert isinstance(args.file, list)
    assert args.file[0] == "my_file.fasta"
    assert args.threads is False
    assert args.max_threads == onecodex.api_v0.DEFAULT_THREADS
コード例 #3
0
ファイル: test_auth.py プロジェクト: arundurvasula/onecodex
def test_auth_login():
    parser = OneCodexArgParser()
    API_KEY = "12345678123456781234567812345678"
    input_args = ["login"]
    with mock.patch("getpass.getpass", return_value=API_KEY):
        args = parser.parse_args(input_args)
        assert not hasattr(args, "credentials")
        OneCodexAuth(args, check_for_update=False, creds_file=TEST_CREDS)
    assert hasattr(args, "credentials")
    assert args.credentials["api_key"] == API_KEY
    assert args.credentials["saved_at"] == datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
    assert args.credentials["updated_at"] is None  # We disable checking in the test
コード例 #4
0
ファイル: test_auth.py プロジェクト: arundurvasula/onecodex
def test_auth_w_32_len_cli_api_key():
    parser = OneCodexArgParser()
    API_KEY = "12345678123456781234567812345678"
    input_args = ["upload", "my_file.fasta",
                  "--api-key", API_KEY]
    args = parser.parse_args(input_args)
    assert not hasattr(args, "credentials")
    OneCodexAuth(args, check_for_update=False, creds_file=TEST_CREDS)
    assert hasattr(args, "credentials")
    assert args.credentials["api_key"] == API_KEY
    assert args.credentials["saved_at"] is None
    assert args.credentials["updated_at"] is None
コード例 #5
0
ファイル: test_auth.py プロジェクト: arundurvasula/onecodex
def test_bad_aws_creds():

    # we modify the env here so we have to clean up
    replace_env = False
    aws_access = None
    aws_secret = None

    if os.environ.get("AWS_ACCESS_KEY_ID"):
        aws_access = os.environ["AWS_ACCESS_KEY_ID"]
        replace_env = True

    if os.environ.get("AWS_SECRET_ACCESS_KEY"):
        aws_secret = os.environ["AWS_SECRET_ACCESS_KEY"]
        replace_env = True

    # set bad credentials in ENV
    # then send the upload request
    try:
        os.environ["AWS_ACCESS_KEY_ID"] = "CRAPPYKEY"
        os.environ["AWS_SECRET_ACCESS_KEY"] = "CRAPPYKEY"
        API_KEY = "12345678123456781234567812345678"
        parser = OneCodexArgParser()
        input_args = ["--api-key", API_KEY, "upload", "big1.fastq"]
        args = parser.parse_args(input_args)
        OneCodexAuth(args, check_for_update=False, creds_file=TEST_CREDS)
        assert hasattr(args, "credentials")
        assert args.credentials["api_key"] == API_KEY
        args.run(args)

    # catch the expected exit
    except SystemExit:

        # clean up the crappy env vars
        if replace_env:
            os.environ["AWS_ACCESS_KEY_ID"] = aws_access
            os.environ["AWS_SECRET_ACCESS_KEY"] = aws_secret
        else:
            del os.environ["AWS_ACCESS_KEY_ID"]
            del os.environ["AWS_SECRET_ACCESS_KEY"]

        # try and find the pidof aws
        # aws should have been killed so this raises CalledProcessError
        check_output(["pidof", "aws"])
    except OSError:
        raise SkipTest("Skipping test - no large fastq file present to test with")
コード例 #6
0
ファイル: cli_tests.py プロジェクト: arundurvasula/onecodex
def test_cli_help_exit_0():
    parser = OneCodexArgParser()
    input_args = ["--help"]
    parser.parse_args(input_args)
コード例 #7
0
ファイル: cli_tests.py プロジェクト: arundurvasula/onecodex
def test_cli_references():
    parser = OneCodexArgParser()
    input_args = ["references"]
    args = parser.parse_args(input_args)
    assert isinstance(args.references, list)
    assert len(args.references) == 0
コード例 #8
0
ファイル: cli_tests.py プロジェクト: arundurvasula/onecodex
def test_cli_analyses_table_error():
    parser = OneCodexArgParser()
    input_args = ["analyses", "uuid1", "uuid2", "--table"]
    args = parser.parse_args(input_args)
    args.run(args)
コード例 #9
0
ファイル: cli_tests.py プロジェクト: arundurvasula/onecodex
def test_cli_analyses():
    parser = OneCodexArgParser()
    input_args = ["analyses", "uuid1", "uuid2", "uuid3"]
    args = parser.parse_args(input_args)
    assert isinstance(args.analyses, list)
    assert len(args.analyses) == 3
コード例 #10
0
ファイル: cli_tests.py プロジェクト: arundurvasula/onecodex
def test_cli_upload_req():
    # Check for required args
    parser = OneCodexArgParser()
    input_args = ["upload"]
    parser.parse_args(input_args)
コード例 #11
0
ファイル: test_auth.py プロジェクト: arundurvasula/onecodex
def test_auth_logout():
    parser = OneCodexArgParser()
    input_args = ["logout"]
    args = parser.parse_args(input_args)
    OneCodexAuth(args, check_for_update=False, creds_file=TEST_CREDS)
    assert not os.path.exists(TEST_CREDS)
コード例 #12
0
ファイル: test_auth.py プロジェクト: arundurvasula/onecodex
def test_auth_login_file_already_exists():
    parser = OneCodexArgParser()
    input_args = ["login"]
    args = parser.parse_args(input_args)
    OneCodexAuth(args, check_for_update=False, creds_file=TEST_CREDS)