# coding: utf-8 module TestSuborders # case 1 (a <- b AND a <- c) def test_001015068_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT015707971'); end def test_001015068_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end def test_001015068_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { ht_number: "HT015707971", label: "Forum Geschichte kompakt", volume_count: "Bd. 2, Teilbd. 1, Von der Frühen Neuzeit bis zum Ersten Weltkrieg [Schülerbd.]", label_additions: nil }) end def test_001015070_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT015707971'); end def test_001015070_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end def test_001015070_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { ht_number: "HT015707971", label: "Forum Geschichte kompakt", volume_count: "Bd. 2, Teilbd. 2, Vom Ende des Ersten Weltkriegs bis zur Gegenwart [Schülerbd.]", label_additions: nil }) end # case 2 (a <- b <- c) def test_001499879_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT017055615'); end; def test_001499879_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_001499879_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { ht_number: "HT017055615", label: "Fakten und Fiktionen", volume_count: "1", label_additions: nil }) end def test_001499880_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT017055615'); end; def test_001499880_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_001499880_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { ht_number: "HT017055615", label: "Fakten und Fiktionen", volume_count: "2", label_additions: nil }) end def test_001499877_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT001260573'); end; def test_001499877_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_001499877_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { ht_number: "HT001260573", label: "Hiersemanns bibliographische Handbücher", volume_count: "21", label_additions: nil }) end # case 3 (b <- a AND c <- a) def test_001006945_has_superorders; assert_has_superorders(doc_id_from_method_name(__method__), ['HT002919097', 'HT003165994']); end; def test_001006945_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_001006945_has_superorder_display assert_has_superorder_display_values(doc_id_from_method_name(__method__), [{ "ht_number" => "HT002919097", "label" => "Urkundenregesten zur Tätigkeit des deutschen Königs- und Hofgerichts bis 1451", "volume_count" => "14", "label_additions" => nil }, { "ht_number" => "HT003165994", "label" => "Quellen und Forschungen zur höchsten Gerichtsbarkeit im alten Reich", "volume_count" => "14", "label_additions" => ["Sonderreihe"] }]) end # case 4 (a <- b) def test_001562173_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT005081594'); end; def test_001562173_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_001562173_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { "ht_number" => "HT005081594", "label" => "Zeitschrift für Familienforschung", "volume_count" => "25,1", "label_additions" => nil }) end # case 5 (b <- a AND c <- a) def test_001572049_has_superorders; assert_has_superorders(doc_id_from_method_name(__method__), ['HT002162049', 'HT017670666']); end; def test_001572049_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_001572049_has_superorder_display assert_has_superorder_display_values(doc_id_from_method_name(__method__), [{ "ht_number" => "HT002162049", "label" => "Paderborner Universitätsreden", "volume_count" => "127", "label_additions" => nil }, { "ht_number" => "HT017670666", "label" => "Paderborner Rathaus-Vorlesungen", "volume_count" => "1", "label_additions" => nil }]) end # case 6 (a <- b AND a <- c) def test_000676616_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT002672902'); end; def test_000676616_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_000676616_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { "ht_number" => "HT002672902", "label" => "Hegel-Jahrbuch", "volume_count" => "1993/94", "label_additions" => nil }) end def test_000392645_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT002672902'); end; def test_000392645_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_000392645_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { "ht_number" => "HT002672902", "label" => "Hegel-Jahrbuch", "volume_count" => "1966", "label_additions" => nil }) end # case 7 (a <- b AND a <- c) def test_000058000_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT000289652'); end; def test_000058000_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_000058000_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { "ht_number" => "HT000289652", "label" => "Sämtliche Werke", "volume_count" => "Stücke 36", "label_additions" => nil }) end def test_001108212_has_superorder; assert_has_superorder(doc_id_from_method_name(__method__), 'HT000289652'); end; def test_001108212_is_suborder; assert_is_suborder(doc_id_from_method_name(__method__)); end; def test_001108212_has_superorder_display assert_has_superorder_display_value(doc_id_from_method_name(__method__), { "ht_number" => "HT000289652", "label" => "Sämtliche Werke / Johann Nestroy", "volume_count" => "", "label_additions" => nil }) end private def assert_has_superorder(doc_id, superorder_id) assert_has_superorders(doc_id, [superorder_id]) end def assert_has_superorder_display_value(doc_id, superorder_display_values) assert_has_superorder_display_values(doc_id, [superorder_display_values]) end def assert_has_superorder_display_values(doc_id, superorder_display_values) doc = Nokogiri::XML(@engine.process('', load_mab('test_suborders', doc_id)).to_xml) superorder_display_nodes = doc.css('superorder_display') superorder_display_values.each_with_index do |superorder_display_value, index| assert_equal(superorder_display_value.stringify_keys, JSON.parse(superorder_display_nodes[index].text)) end end def assert_has_superorders(doc_id, superorder_ids) doc = Nokogiri::XML(@engine.process('', load_mab('test_suborders', doc_id)).to_xml) superorders = doc.css('superorder') assert_equal(true, superorders.present?) assert_equal(superorder_ids.length, superorders.length) superorder_ids.each do |superorder_id| assert_includes(superorders.map(&:text), superorder_id) end end def assert_is_suborder(doc_id) doc = Nokogiri::XML(@engine.process('', load_mab('test_suborders', doc_id)).to_xml) assert_equal(true, (value = doc.css('is_suborder').text).present?) assert_equal('true', value) end def doc_id_from_method_name(method_name) method_name[/\d+/] end end