def test_can_get_all_provider_history_with_newest_first(setup_sms_providers_with_history):
    [inactive_provider, current_provider, alternative_provider] = setup_sms_providers_with_history
    current_provider.priority += 1
    dao_update_provider_details(current_provider)
    versions = dao_get_provider_versions(current_provider.id)
    assert len(versions) == 2
    assert versions[0].version == 2
def test_toggle_sms_provider_updates_provider_history(
    mocker,
    sample_user,
    setup_sms_providers_with_history
):
    [inactive_provider, current_provider, alternative_provider] = setup_sms_providers_with_history
    mocker.patch('app.provider_details.switch_providers.get_user_by_id', return_value=sample_user)
    mocker.patch('app.dao.provider_details_dao.get_alternative_sms_provider', return_value=alternative_provider)

    current_provider_history = dao_get_provider_versions(current_provider.id)

    dao_toggle_sms_provider(current_provider.identifier)

    updated_provider_history_rows = dao_get_provider_versions(current_provider.id)

    assert len(updated_provider_history_rows) - len(current_provider_history) == 1
    assert updated_provider_history_rows[0].version - current_provider_history[0].version == 1
Beispiel #3
0
def test_can_get_all_provider_history(current_sms_provider):
    assert len(dao_get_provider_versions(current_sms_provider.id)) == 2
Beispiel #4
0
def get_provider_versions(provider_details_id):
    versions = dao_get_provider_versions(provider_details_id)
    data = provider_details_history_schema.dump(versions, many=True).data
    return jsonify(data=data)