<commit_before>require 'test_helper'

class IntegrationTest < Minitest::Test

  def setup
    skip if ENV['USER_ID'].nil? || ENV['USER_ID'].empty?

    disable_vcr!

    @user_id = ENV['USER_ID']
    @user = authenticated_client.users.find(@user_id)
    @user_client = authenticated_client.users.authenticate_as(id: @user_id, refresh_token: @user[:refresh_token])
  end

  def teardown
    skip if ENV['USER_ID'].nil? || ENV['USER_ID'].empty?

    @user_id = nil
    @user = nil
    @user_client = nil

    enable_vcr!
  end

  def test_users_all
    users = authenticated_client.users.all

    assert_equal '200', users[:http_code]
    assert_equal '0', users[:error_code]
    assert users[:success]
    refute_nil users[:users]
  end

  def test_user_find
    user = authenticated_client.users.find(@user_id)

    refute_predicate user[:_id], :empty?
    refute_predicate user[:refresh_token], :empty?
    refute_predicate user[:legal_names], :empty?
  end

  def test_create_user_with_fingerprint
    user = authenticated_client.users.create(name: '<NAME>', email: '<EMAIL>', phone: '123-456-8790', fingerprint: 'abc123')
    user_client = authenticated_client.users.authenticate_as(id: user[:_id], refresh_token: user[:refresh_token], fingerprint: 'abc123')

    response = user_client.nodes.all
    assert response[:success]

    bank = user_client.add_bank_account(
      name: '<NAME>',
      account_number: '123456786',
      routing_number: '051000017',
      category: 'PERSONAL',
      type: 'CHECKING'
    )
    assert bank[:success]

    node_id = bank[:nodes].first[:_id]
<commit_msg>Test that response data is set on user_client<commit_after>require 'test_helper'

class IntegrationTest < Minitest::Test

  def setup
    skip if ENV['USER_ID'].nil? || ENV['USER_ID'].empty?

    disable_vcr!

    @user_id = ENV['USER_ID']
    @user = authenticated_client.users.find(@user_id)
    @user_client = authenticated_client.users.authenticate_as(id: @user_id, refresh_token: @user[:refresh_token])
  end

  def teardown
    skip if ENV['USER_ID'].nil? || ENV['USER_ID'].empty?

    @user_id = nil
    @user = nil
    @user_client = nil

    enable_vcr!
  end

  def test_users_all
    users = authenticated_client.users.all

    assert_equal '200', users[:http_code]
    assert_equal '0', users[:error_code]
    assert users[:success]
    refute_nil users[:users]
  end

  def test_user_find
    user = authenticated_client.users.find(@user_id)

    refute_predicate user[:_id], :empty?
    refute_predicate user[:refresh_token], :empty?
    refute_predicate user[:legal_names], :empty?
  end

  def test_create_user_with_fingerprint
    user = authenticated_client.users.create(name: '<NAME>', email: '<EMAIL>', phone: '123-456-8790', fingerprint: 'abc<PASSWORD>')
    user_client = authenticated_client.users.authenticate_as(id: user[:_id], refresh_token: user[:refresh_token], fingerprint: 'abc123')

    refute_nil user_client.expires_at
    refute_nil user_client.expires_in
    refute_nil user_client.refresh_expires_in
    refute_nil user_client.refresh_token

    response = user_client.nodes.all
    assert response[:success]

    bank = user_client.add_bank_account(
      name: '<NAME>',
      account_number: '123456786',
      routing_number: '051000017',
      category: 'PERSONAL',
      type: 'CHECKING'
    )
    assert bank[:success]

    node_id = bank[:nodes].first[:_id]

{'fraction_non_alphanumeric': 0.12055277859453102, 'fraction_numerical': 0.021464275213172596, 'mean_word_length': 4.131221719457014, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1427930', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1143, 'n_words': 221}