Beispiel #1
0
def test_login_clears_unregistered(setup_database):
    '''Test that login clears unregistered flag.'''
    login = database.upsert_login(1, 7)
    device = database.upsert_device(login_id=login.id,
                                    platform_id=1,
                                    device_token='100',
                                    application_version=1001)

    # unregister
    database.update_unregistered_devices([{
        'login_id': login.id,
        'device_token': device.device_token
    }])
    for users_device in database.get_devices(login):
        assert users_device.unregistered_ts is not None

    # reregister user with device token
    database.process_user_login(login_id=login.id,
                                language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token=device.device_token,
                                application_version=device.application_version)

    # reregistered user's device should clear unregistered flag
    for users_device in database.get_devices(login):
        assert users_device.unregistered_ts is None
Beispiel #2
0
def test_login_clears_unregistered_new_device_token(setup_database):
    '''Test that login clears unregistered flag with new device token set.'''
    login = database.upsert_login(1, 7)
    device = database.upsert_device(login_id=login.id, platform_id=1, device_token='100', application_version=1001)
    # set new device token
    canonical_data = [{'login_id': login.id, 'old_token': device.device_token, 'new_token': '100a'}]
    database.update_canonicals(canonical_data)

    # unregister
    database.update_unregistered_devices([{'login_id': login.id, 'device_token': '100a'}])
    for users_device in database.get_devices(login):
        assert users_device.unregistered_ts is not None
    # reregister user with old device token
    database.process_user_login(login_id=login.id, language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token=device.device_token,
                                application_version=device.application_version)
    # reregistered user's device should clear unregistered flag
    for users_device in database.get_devices(login):
        assert users_device.unregistered_ts is None

    # unregister
    database.update_unregistered_devices([{'login_id': login.id, 'device_token': '100a'}])
    for users_device in database.get_devices(login):
        assert users_device.unregistered_ts is not None
    # reregister user with device token new
    database.process_user_login(login_id=login.id, language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token='100a',
                                application_version=device.application_version)
    # reregistered user's device should clear unregistered flag
    for users_device in database.get_devices(login):
        assert users_device.unregistered_ts is None
Beispiel #3
0
def test_device_update_application_version_new_device_token(setup_database):
    '''Test that application_version is updated on login with new device token.'''
    login = database.upsert_login(1, 7)
    device = database.upsert_device(login_id=login.id,
                                    platform_id=1,
                                    device_token='100',
                                    application_version=1)
    # set new device token
    canonical_data = [{
        'login_id': login.id,
        'old_token': device.device_token,
        'new_token': '100a'
    }]
    database.update_canonicals(canonical_data)

    # update application version via old device token
    database.process_user_login(login_id=login.id,
                                language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token=device.device_token,
                                application_version=2)
    for users_device in database.get_devices(login):
        assert users_device.application_version == 2

    # update application version via new device token
    database.process_user_login(login_id=login.id,
                                language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token='100a',
                                application_version=3)
    for users_device in database.get_devices(login):
        assert users_device.application_version == 3
Beispiel #4
0
def test_user(setup_database):
    login = database.upsert_login(12345, 7)
    reloaded_login = database.get_login(12345)
    assert login.id == reloaded_login.id
    assert login.language_id == reloaded_login.language_id


    device = database.upsert_device(login_id=login.id, platform_id=1, device_token='123',
                                    application_version=1001, unregistered_ts=datetime.datetime.now())
    reloaded_devices = database.get_devices(login)
    assert device.id == reloaded_devices[0].id
    assert device.login_id == reloaded_devices[0].login_id
    assert device.platform_id == reloaded_devices[0].platform_id
    assert device.device_token == reloaded_devices[0].device_token

    database.delete_device(device)
    assert len(database.get_devices(login)) == 0

    database.delete_login(login)
    assert database.get_login(12345) is None
Beispiel #5
0
def test_user(setup_database):
    login = database.upsert_login(12345, 7)
    reloaded_login = database.get_login(12345)
    assert login.id == reloaded_login.id
    assert login.language_id == reloaded_login.language_id


    device = database.upsert_device(login_id=login.id, platform_id=1, device_token='123',
                                    application_version=1001, unregistered_ts=datetime.datetime.now())
    reloaded_devices = database.get_devices(login)
    assert device.id == reloaded_devices[0].id
    assert device.login_id == reloaded_devices[0].login_id
    assert device.platform_id == reloaded_devices[0].platform_id
    assert device.device_token == reloaded_devices[0].device_token

    database.delete_device(device)
    assert len(database.get_devices(login)) == 0

    database.delete_login(login)
    assert database.get_login(12345) is None
Beispiel #6
0
def test_device_update_application_version(setup_database):
    '''Test that application_version is updated on login'''
    login = database.upsert_login(1, 7)
    device = database.upsert_device(login_id=login.id, platform_id=1, device_token='100', application_version=1)
    database.process_user_login(login_id=login.id, language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token=device.device_token,
                                application_version=2)

    for users_device in database.get_devices(login):
        assert users_device.application_version == 2
Beispiel #7
0
def test_device_update_application_version(setup_database):
    '''Test that application_version is updated on login'''
    login = database.upsert_login(1, 7)
    device = database.upsert_device(login_id=login.id, platform_id=1, device_token='100', application_version=1)
    database.process_user_login(login_id=login.id, language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token=device.device_token,
                                application_version=2)

    for users_device in database.get_devices(login):
        assert users_device.application_version == 2
Beispiel #8
0
def test_device_update_application_version_new_device_token(setup_database):
    '''Test that application_version is updated on login with new device token.'''
    login = database.upsert_login(1, 7)
    device = database.upsert_device(login_id=login.id, platform_id=1, device_token='100', application_version=1)
    # set new device token
    canonical_data = [{'login_id': login.id, 'old_token': device.device_token, 'new_token': '100a'}]
    database.update_canonicals(canonical_data)

    # update application version via old device token
    database.process_user_login(login_id=login.id, language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token=device.device_token,
                                application_version=2)
    for users_device in database.get_devices(login):
        assert users_device.application_version == 2

    # update application version via new device token
    database.process_user_login(login_id=login.id, language_id=login.language_id,
                                platform_id=device.platform_id,
                                device_token='100a',
                                application_version=3)
    for users_device in database.get_devices(login):
        assert users_device.application_version == 3