Sha256: c79891eff93435adfdea4cef36476a2fe939ab38d23714a978cc8e08afb3f40c

Contents?: true

Size: 1.99 KB

Versions: 8

Compression:

Stored size: 1.99 KB

Contents

require 'test_helper'

class InstitutionListTest < ActiveSupport::TestCase

  def setup
    InstitutionList.class_variable_set(:@@institutions_yaml_path, nil)
    InstitutionList.instance.instance_variable_set(:@institutions, nil)
    @yaml_path = "#{File.dirname(__FILE__)}/../support/config/institutions.yml"
    @yaml2_path = "#{File.dirname(__FILE__)}/../support/config/institutions2.yml"
  end
  
  test "yaml_path" do
    assert_raise ArgumentError do
      InstitutionList.yaml_path=  nil
    end
    assert_raise NameError do
      InstitutionList.yaml_path= "garbage_path"
    end
    assert_nothing_raised do
      InstitutionList.yaml_path= @yaml_path
      InstitutionList.instance.institutions
    end
  end
  
  test "defined" do
    assert(!InstitutionList.institutions_defined?)
    InstitutionList.yaml_path= @yaml_path
    assert(InstitutionList.institutions_defined?)
  end
  
  test "defaults" do
    assert_raise ArgumentError do
      InstitutionList.instance.defaults
    end
    assert_nothing_raised do
      InstitutionList.yaml_path= @yaml_path
      InstitutionList.instance.defaults
    end
    assert_not_nil(InstitutionList.instance.defaults)
    assert_equal([InstitutionList.instance.get("NYUAD")], InstitutionList.instance.defaults)
  end
  
  test "institutions_with_ip" do
    assert_raise ArgumentError do
      InstitutionList.instance.institutions_with_ip "128.122.149.122"
    end
    assert_nothing_raised do
      InstitutionList.yaml_path= @yaml_path
      InstitutionList.instance.institutions_with_ip "128.122.149.122"
    end
    assert_not_nil(InstitutionList.instance.institutions_with_ip "128.122.149.122")
    assert_equal([InstitutionList.instance.get("NYU")], InstitutionList.instance.institutions_with_ip("128.122.149.122"))
  end
  
  test "parents" do
    institution_list = YAML.load_file( @yaml2_path )
    # nyu = institution_list["NYU"]
    # puts "Test:#{institution_list}"
    InstitutionList.yaml_path= @yaml2_path
    InstitutionList.instance.institutions
    
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
authpds-0.1.2 test/unit/institution_list_test.rb
authpds-0.1.1 test/unit/institution_list_test.rb
authpds-0.1.0 test/unit/institution_list_test.rb
authpds-0.0.23 test/unit/institution_list_test.rb
authpds-0.0.22 test/unit/institution_list_test.rb
authpds-0.0.21 test/unit/institution_list_test.rb
authpds-0.0.20 test/unit/institution_list_test.rb
authpds-0.0.19 test/unit/institution_list_test.rb