Skip to content

Commit

Permalink
update tests to match new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
wkdewey committed Sep 20, 2024
1 parent 9b156f2 commit 3d59f09
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 29 deletions.
12 changes: 7 additions & 5 deletions test/csv_to_es_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ class CsvToEsTest < Minitest::Test

def setup
path = File.join($fixture_path, "csv", "testing.csv")
csv = CSV.read(path, headers: true)

csv = CSV.read(path, **{
encoding: "utf-8",
headers: true,
})
$options["api_version"] = "2.0"
@test1 = CsvToEs.new(csv[0], $options, csv)
@test2 = CsvToEs.new(csv[1], $options, csv)
end

def test_assemble_json
json = @test1.assemble_json
assert_equal 42, json.length
assert_equal 58, json.length
assert_equal "test.001", json["identifier"]

json = @test2.assemble_json
assert_equal 42, json.length
assert_equal 58, json.length
assert_equal "test.002", json["identifier"]
end

def test_csv_to_es_fields
json = @test1.assemble_json
assert_equal "1887-01-01", json["date"]

contributors = [{"name"=>"Jessica Dussault"}, {"name"=>"Greg Tunink"}, {"name"=>"Karin Dalziel"}]
assert_equal contributors, json["contributor"]

Expand Down
2 changes: 1 addition & 1 deletion test/helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_date_standardize
def test_get_directory_files
# real directory
files = Datura::Helpers.get_directory_files("#{File.dirname(__FILE__)}/fixtures")
assert_equal 6, files.length
assert_equal 7, files.length

# not a real directory
files = Datura::Helpers.get_directory_files("/fake")
Expand Down
2 changes: 1 addition & 1 deletion test/html_to_es_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def setup

def test_assemble_json
json = @test.assemble_json
assert_equal 42, json.length
assert_equal 58, json.length
assert_equal "testing", json["identifier"]
end

Expand Down
35 changes: 18 additions & 17 deletions test/tei_to_es_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setup

def test_assemble_json
json = @neihardt.assemble_json
assert_equal 42, json.length
assert_equal 58, json.length
assert_equal "nei.j4c.12.52", json["identifier"]
end

Expand All @@ -26,11 +26,11 @@ def test_fields
creator = [{"name"=>"Neihardt, John Gneisenau, 1881-1973"}]
assert_equal creator, neihardt["creator"]

contributor = [{"id"=>"lkw", "name"=>"Weakly, Laura K.", "role"=>""},
{"id"=>"swa", "name"=>"Adrales, Samantha W.", "role"=>""},
{"id"=>"az", "name"=>"Zeljkovic, Arman", "role"=>""},
{"id"=>"ep", "name"=>"Pedigo, Erin", "role"=>""},
{"id"=>"", "name"=>"Gossin, Pamela", "role"=>""}
contributor = [{"id"=>"lkw", "name"=>"Weakly, Laura K.", "role"=>nil},
{"id"=>"swa", "name"=>"Adrales, Samantha W.", "role"=>nil},
{"id"=>"az", "name"=>"Zeljkovic, Arman", "role"=>nil},
{"id"=>"ep", "name"=>"Pedigo, Erin", "role"=>nil},
{"id"=>nil, "name"=>"Gossin, Pamela", "role"=>nil}
]
assert_equal contributor, neihardt["contributor"]

Expand All @@ -40,18 +40,19 @@ def test_fields
assert_equal "late 1865 (?)", whitman["date_display"]
assert_equal "1865-12-31", whitman["date_not_after"]
assert_equal "1865-07-01", whitman["date_not_before"]

# source
source = "Track and stable talk, Aberdeen, South Dakota, 1888-02-24"
assert_equal source, cody["source"]

source = "Neihardt, John Gneisenau, 1881-1973, Letter from John G. Neihardt to Julius T. House, 1927-11-05"
assert_equal source, neihardt["source"]

# NOTE: this document does have publisher information in the biblStruct and will
# need to override the default xpaths to obtain that information for the source field
source = "Walt Whitman, Walt Whitman to a Soldier, late 1865 (?)"
assert_equal source, whitman["source"]
# note that source has been replaced by has_source
# TeiToES at this point does not define default behavior for this field
# source = "Track and stable talk, Aberdeen, South Dakota, 1888-02-24"
# assert_equal source, cody["has_source"]

# source = "Neihardt, John Gneisenau, 1881-1973, Letter from John G. Neihardt to Julius T. House, 1927-11-05"
# assert_equal source, neihardt["has_source"]

# # NOTE: this document does have publisher information in the biblStruct and will
# # need to override the default xpaths to obtain that information for the source field
# source = "Walt Whitman, Walt Whitman to a Soldier, late 1865 (?)"
# assert_equal source, whitman["has_source"]

end
end
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"collection" => "test_collection",
"data_base" => "cdrhtest.unl.edu/media",
"environment" => "test",
"site_url" => "cdrhtest.unl.edu"
"site_url" => "cdrhtest.unl.edu",
"api_version" => "2.0"
}

current_dir = File.expand_path(File.dirname(__FILE__))
Expand Down
6 changes: 3 additions & 3 deletions test/vra_to_es_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def setup

def test_assemble_json
json = @cody.assemble_json
assert_equal 42, json.length
assert_equal 58, json.length
assert_equal "wfc.img.pho.69.236.82", json["identifier"]
end

Expand All @@ -22,8 +22,8 @@ def test_vra_to_es_fields
assert_equal keywords, json["keywords"]

people = [
{id: nil, name: "Käsebier, Gertrude, 1852-1934", role: "photographer"},
{id: nil, name: "Spotted Horse, Willie", role: nil}
{"id" => nil, "name" => "Käsebier, Gertrude, 1852-1934", "role" => "photographer"},
{"id" => nil, "name" => "Spotted Horse, Willie", "role" => nil}
]
assert_equal people, json["person"]
end
Expand Down
2 changes: 1 addition & 1 deletion test/webs_to_es_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def setup

def test_assemble_json
json = @test.assemble_json
assert_equal 42, json.length
assert_equal 58, json.length
assert_equal "testing", json["identifier"]
end

Expand Down

0 comments on commit 3d59f09

Please sign in to comment.