<commit_before>require_relative 'test_helper'

class SearchTest < ActiveSupport::TestCase

  def setup
    @person = create_user('testing').person
  end
  attr_reader :person

  should 'return the default environment' do
    default = Environment.default
    get "/api/v1/environment/default"
    json = JSON.parse(last_response.body)
    assert_equal default.id, json['id']
  end

  should 'return created environment' do
    other = fast_create(Environment)
    default = Environment.default
    assert_not_equal other.id, default.id
    get "/api/v1/environment/#{other.id}"
    json = JSON.parse(last_response.body)
    assert_equal other.id, json['id']
  end

  should 'return context environment' do
    contextEnv = fast_create(Environment)
    contextEnv.name = "example.org"
    contextEnv.save
    default = Environment.default
    assert_not_equal contextEnv.id, default.id
    get "/api/v1/environment/context"
    json = JSON.parse(last_response.body)
    assert_equal contextEnv.id, json['id']
  end  

  should 'return environment boxes' do
    default = Environment.default
    default.boxes << Box.new
    default.boxes[0].blocks << Block.new
    default.save!
    assert !default.boxes.empty?
    get "/api/v1/environments/#{default.id}/boxes"
    json = JSON.parse(last_response.body)
    assert_equal "boxes", json.first[0]
    assert_not_equal [], json.first[1]
  end

end<commit_msg>cosmetic changes<commit_after>require_relative 'test_helper'

class SearchTest < ActiveSupport::TestCase

  def setup
    @person = create_user('testing').person
  end
  attr_reader :person

  should 'return the default environment' do
    environment = Environment.default
    get "/api/v1/environment/default"
    json = JSON.parse(last_response.body)
    assert_equal environment.id, json['id']
  end

  should 'return created environment' do
    environment = fast_create(Environment)
    default_env = Environment.default
    assert_not_equal environment.id, default_env.id
    get "/api/v1/environment/#{environment.id}"
    json = JSON.parse(last_response.body)
    assert_equal environment.id, json['id']
  end

  should 'return context environment' do
    context_env = fast_create(Environment)
    context_env.name = "example.org"
    context_env.save
    default_env = Environment.default
    assert_not_equal context_env.id, default_env.id
    get "/api/v1/environment/context"
    json = JSON.parse(last_response.body)
    assert_equal context_env.id, json['id']
  end  

  should 'return environment boxes' do
    environment = Environment.default
    environment.boxes << Box.new
    box = environment.boxes.last
    environment.boxes[0].blocks << Block.new
    environment.save!
    assert !environment.boxes.empty?
    get "/api/v1/environments/#{environment.id}/boxes"
    json = JSON.parse(last_response.body)
    assert_equal "boxes", json.first[0]
    assert_equal box.id, json['boxes'].first['id']
  end

end
{'fraction_non_alphanumeric': 0.10494037478705281, 'fraction_numerical': 0.004429301533219762, 'mean_word_length': 3.7051282051282053, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, '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': '952858', 'n_tokens_mistral': 886, 'n_tokens_neox': 876, 'n_words': 195}