예제 #1
0
파일: test_premium.py 프로젝트: rotki/rotki
def test_try_premium_at_start_first_time_no_previous_db(
        rotkehlchen_instance,
        username,
        db_password,
        rotki_premium_credentials,
):
    """Regression test for:
    - https://github.com/rotki/rotki/issues/1571
    - https://github.com/rotki/rotki/issues/2846
    """
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=True,
        same_hash_with_remote=False,
        newer_remote_db=False,
        db_can_sync_setting=True,
        remote_data=None,
    )
    # DB should not have changed and no exception raised
    assert rotkehlchen_instance.data.db.get_main_currency() == DEFAULT_TESTS_MAIN_CURRENCY
    # DB should have the given rotki premium credentials saved in it since premium
    # was succesfully initialized
    credentials = rotkehlchen_instance.data.db.get_rotkehlchen_premium()
    assert credentials is not None
    assert credentials.api_key == rotki_premium_credentials.api_key
    assert credentials.api_secret == rotki_premium_credentials.api_secret
예제 #2
0
파일: test_premium.py 프로젝트: rotki/rotki
def test_try_premium_at_start_old_account_can_pull_data(
        rotkehlchen_instance,
        username,
        db_password,
        rotki_premium_credentials,
):
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=False,
        same_hash_with_remote=False,
        newer_remote_db=True,
        db_can_sync_setting=True,
    )
    assert_db_got_replaced(rotkehlchen_instance=rotkehlchen_instance, username=username)
예제 #3
0
파일: test_premium.py 프로젝트: rotki/rotki
def test_try_premium_at_start_old_account_older_remote_ts_smaller_remote_size(
        rotkehlchen_instance,
        username,
        db_password,
        rotki_premium_credentials,
):
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=False,
        same_hash_with_remote=False,
        newer_remote_db=False,
        db_can_sync_setting=True,
    )
    # DB should not have changed
    assert rotkehlchen_instance.data.db.get_main_currency() == DEFAULT_TESTS_MAIN_CURRENCY
예제 #4
0
파일: test_premium.py 프로젝트: rotki/rotki
def test_try_premium_at_start_new_account_can_pull_data(
        rotkehlchen_instance,
        username,
        db_password,
        rotki_premium_credentials,
):
    # Test that even with can_sync False, at start of new account we attempt data pull
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=True,
        same_hash_with_remote=False,
        newer_remote_db=True,
        db_can_sync_setting=False,
    )
    assert_db_got_replaced(rotkehlchen_instance=rotkehlchen_instance, username=username)
예제 #5
0
def test_try_premium_at_start_old_account_doesnt_pull_data_with_no_premium_sync(
    rotkehlchen_instance,
    username,
    db_password,
    rotki_premium_credentials,
):
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=False,
        same_hash_with_remote=False,
        newer_remote_db=True,
        db_can_sync_setting=False,
    )
    # DB should not have changed
    assert rotkehlchen_instance.data.db.get_main_currency() == A_USD
예제 #6
0
def test_try_premium_at_start_old_account_newer_remote_ts_smaller_remote_size(
    rotkehlchen_instance,
    username,
    db_password,
    rotki_premium_credentials,
):
    """Assure that newer remote ts and smaller remote size asks the user for sync"""
    with pytest.raises(RotkehlchenPermissionError):
        setup_starting_environment(
            rotkehlchen_instance=rotkehlchen_instance,
            username=username,
            db_password=db_password,
            premium_credentials=rotki_premium_credentials,
            first_time=False,
            same_hash_with_remote=False,
            newer_remote_db=True,
            db_can_sync_setting=True,
            sync_approval='unknown',
        )
예제 #7
0
def test_try_premium_at_start_first_time_no_previous_db(
        rotkehlchen_instance,
        username,
        db_password,
        rotki_premium_credentials,
):
    """Regression test for https://github.com/rotki/rotki/issues/1571"""
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=True,
        same_hash_with_remote=False,
        newer_remote_db=False,
        db_can_sync_setting=True,
        remote_data=None,
    )
    # DB should not have changed and no exception raised
    assert rotkehlchen_instance.data.db.get_main_currency() == DEFAULT_TESTS_MAIN_CURRENCY
예제 #8
0
def test_try_premium_at_start_old_account_older_remote_ts(
    rotkehlchen_instance,
    username,
    db_password,
    rotkehlchen_api_key,
    rotkehlchen_api_secret,
):
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        api_key=rotkehlchen_api_key,
        api_secret=rotkehlchen_api_secret,
        first_time=False,
        same_hash_with_remote=False,
        newer_remote_db=False,
        db_can_sync_setting=True,
    )
    # DB should not have changed
    assert rotkehlchen_instance.data.db.get_main_currency() == A_USD
예제 #9
0
파일: test_premium.py 프로젝트: rotki/rotki
def test_try_premium_at_start_new_account_rejects_data(
        rotkehlchen_instance,
        username,
        db_password,
        rotki_premium_credentials,
):
    # Test that even with can_sync False, at start of new account we attempt data pull
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=True,
        same_hash_with_remote=False,
        newer_remote_db=True,
        db_can_sync_setting=False,
        sync_database=False,
    )
    msg = 'Test default main currency should be different from the restored currency'
    assert DEFAULT_TESTS_MAIN_CURRENCY != A_GBP, msg
    assert rotkehlchen_instance.data.db.get_main_currency() == DEFAULT_TESTS_MAIN_CURRENCY
예제 #10
0
def test_try_premium_at_start_new_account_different_password_than_remote_db(
    rotkehlchen_instance,
    username,
    db_password,
    rotki_premium_credentials,
):
    """
    If we make a new account with api keys and provide a password different than
    the one the remote DB is encrypted with then make sure that PremiumAuthenticationError
    is thrown and that it is shown to the user.
    """
    with pytest.raises(PremiumAuthenticationError):
        setup_starting_environment(
            rotkehlchen_instance=rotkehlchen_instance,
            username=username,
            db_password=db_password,
            premium_credentials=rotki_premium_credentials,
            first_time=True,
            same_hash_with_remote=False,
            newer_remote_db=False,
            db_can_sync_setting=True,
        )
예제 #11
0
파일: test_premium.py 프로젝트: rotki/rotki
def test_try_premium_at_start_old_account_can_pull_old_data(
        rotkehlchen_instance,
        username,
        db_password,
        rotki_premium_credentials,
):
    """
    Test that if the remote DB is of an old version its upgraded before replacing our current

    For an old account
    """
    setup_starting_environment(
        rotkehlchen_instance=rotkehlchen_instance,
        username=username,
        db_password=db_password,
        premium_credentials=rotki_premium_credentials,
        first_time=False,
        same_hash_with_remote=False,
        newer_remote_db=True,
        db_can_sync_setting=True,
        remote_data=REMOTE_DATA_OLDER_DB,
    )
    assert_db_got_replaced(rotkehlchen_instance=rotkehlchen_instance, username=username)
예제 #12
0
def test_try_premium_at_start_new_account_different_password_than_remote_db(
    rotkehlchen_instance,
    username,
    db_password,
    rotkehlchen_api_key,
    rotkehlchen_api_secret,
):
    """
    If we make a new account with api keys and provide a password different than
    the one the remote DB is encrypted with then make sure that UnableToDecryptRemoteData
    is thrown and that it is shown to the user.
    """
    with pytest.raises(UnableToDecryptRemoteData):
        setup_starting_environment(
            rotkehlchen_instance=rotkehlchen_instance,
            username=username,
            db_password=db_password,
            api_key=rotkehlchen_api_key,
            api_secret=rotkehlchen_api_secret,
            first_time=True,
            same_hash_with_remote=False,
            newer_remote_db=False,
            db_can_sync_setting=True,
        )