Example #1
0
def test_leader():
    print(marcdata.marc_tuple(REC1))

    marc = marcdata.marc_tuple(REC1)
    ldr = marc[0]
    assert ldr == ("c", "a", "m", " ", "a", 2, 2, 205, "1", " ", " ", 4, 5, 0,
                   0)
Example #2
0
def test_visual_materials():
    marc = marcdata.marc_tuple(REC_VM)
    assert marcdata.utils.material_type(marc) == "VM"
    assert marcdata.utils.fixed_length_tuple(marc) == \
        ("991028", "s", "    ", "    ", "xxu",
         ("   ", " ", " ", "     ", " ", " ", "   ", "v", "|"),
         "eng", " ", " ")
Example #3
0
def test_continuing_resource():
    marc = marcdata.marc_tuple(REC_CR)
    assert marcdata.utils.material_type(marc) == "CR"
    assert marcdata.utils.fixed_length_tuple(marc) == \
        ("940906", "u", "1994", "9999", "dcu",
         ("u", "u", " ", " ", " ", " ", " ",
          "   ", " ", "0", "   ", " ", "0"), "eng", " ", " ")
Example #4
0
def test_music():
    marc = marcdata.marc_tuple(REC_MU)
    assert marcdata.utils.material_type(marc) == "MU"
    assert marcdata.utils.fixed_length_tuple(marc) == \
        ("000824", "s", "1998", "    ", "nyu",
         ("pp", "n", " ", " ", " ", "      ", "  ", " ", " ", " "),
         "   ", " ", "d")
Example #5
0
def test_computer_file():
    marc = marcdata.marc_tuple(REC_CF)
    assert marcdata.utils.material_type(marc) == "CF"
    assert marcdata.utils.fixed_length_tuple(marc) == \
        ("000110", "s", "2000", "    ", "ohu",
         ("    ", "f", " ", "  ", "m", " ", " ", "      "),
         "eng", " ", " ")
Example #6
0
def test_map():
    marc = marcdata.marc_tuple(REC_MP)
    assert marcdata.utils.material_type(marc) == "MP"
    assert marcdata.utils.fixed_length_tuple(marc) == \
        ("940812", "m", "1898", "1906", "pau",
         ("    ", "  ", " ", "e", "  ", " ", " ", " ", " ", " ", "  "),
         "eng", " ", " ")
Example #7
0
def test_subfields():
    marc = marcdata.marc_tuple(REC1)
    title = marcdata.find(marc, "245")[0]
    assert len(marcdata.find_subf(title)) == 3
    assert marcdata.find_subf(title, "a") == \
        (("a", "Botanical materia medica and pharmacology;"),)
    assert marcdata.find_subf(title, "c") == \
        (("c", "By S. H. Aurand."),)
    assert marcdata.find_subf(title, "z") == ()
Example #8
0
def test_mat_desc_dict_mx():
    fd = marcdata.utils.fixed_length_dict(marcdata.marc_tuple(REC_MX))
    assert "target_audience" not in fd
    assert "form_of_item" in fd
    assert "illustrations" not in fd
    assert "type_of_computer_file" not in fd
    assert "type_of_cartographic_material" not in fd
    assert "form_of_composition" not in fd
    assert "type_of_continuing_resource" not in fd
    assert "type_of_visual_material" not in fd
Example #9
0
def test_find_with_indicators():
    marc = marcdata.marc_tuple(REC1)
    title = (("245", "1", "0", (
        "a", "Botanical materia medica and pharmacology;"
    ), ("b",
        "drugs considered from a botanical, pharmaceutical, physiological, therapeutical and toxicological standpoint."
        ), ("c", "By S. H. Aurand.")), )
    assert marcdata.find(marc, "245", ind1="x") == ()
    assert marcdata.find(marc, "245", ind1="1") == title

    assert marcdata.find(marc, "245", ind2="x") == ()
    assert marcdata.find(marc, "245", ind2="0") == title

    assert marcdata.find(marc, "245", ind1="1", ind2="x") == ()
    assert marcdata.find(marc, "245", ind1="1", ind2="0") == title
Example #10
0
def test_leader_dict():
    marc = marcdata.utils.marc_dict(marcdata.marc_tuple(REC1))
    print(marc.keys())
    ldr = marc["leader"]

    assert ldr["record_status"] == "c"
    assert ldr["type_of_record"] == "a"
    assert ldr["bibliographic_level"] == "m"
    assert ldr["type_of_control"] == " "
    assert ldr["character_encoding_scheme"] == "a"
    assert ldr["indicator_count"] == 2
    assert ldr["subfield_code_count"] == 2
    assert ldr["base_address_of_data"] == 205
    assert ldr["encoding_level"] == "1"
    assert ldr["descriptive_cataloging_form"] == " "
    assert ldr["multipart_resource_record_level"] == " "
    assert ldr["length_of_length_of_field_portion"] == 4
    assert ldr["length_of_starting_character_position_portion"] == 5
    assert ldr["length_of_implication_defined_portion"] == 0
Example #11
0
def test_marc_dict():
    md = marcdata.utils.marc_dict(marcdata.marc_tuple(REC1))

    # Control field has one value
    assert len(md["003"]) == 1
    assert md["003"][0]["type"] == "control"
    assert md["003"][0]["value"] == "DLC"

    # 008 field is a dict
    assert type(md["008"][0]["value"]) == dict

    # The 650 field has two values
    assert len(md["650"]) == 2

    # The second 650 has two subfields
    assert md["650"][1]["type"] == "variable"
    assert md["650"][1]["ind1"] == " "
    assert md["650"][1]["ind2"] == "0"
    assert len(md["650"][1]["subfields"]) == 2
    assert md["650"][1]["subfields"]["a"] == "Homeopathy"
    assert md["650"][1]["subfields"]["x"] == "Materia medica and therapeutics."
Example #12
0
def test_find_none():
    marc = marcdata.marc_tuple(REC1)
    assert marcdata.find(marc, "XYZ") == ()
Example #13
0
def test_find_multiple():
    marc = marcdata.marc_tuple(REC1)
    assert len(marcdata.find(marc, "650")) == 2
Example #14
0
def test_find():
    marc = marcdata.marc_tuple(REC1)
    assert marcdata.find(marc, "010") == \
        (("010", " ", " ", ("a", "   00000002 ")),)
Example #15
0
def test_control_value():
    marc = marcdata.marc_tuple(REC1)
    f008 = marc[1][3]
    assert marcdata.control_value(f008) == \
        "800108s1899    ilu           000 0 eng  "
Example #16
0
def test_fixed_length_tuple():
    marc = marcdata.marc_tuple(REC1)
    assert marcdata.utils.fixed_length_tuple(marc) == \
        ("800108", "s", "1899", "    ", "ilu",
         ("    ", " ", " ", "    ", " ", "0", "0", "0", " ", "0", " "),
         "eng", " ", " ")
Example #17
0
def test_mixed_materials():
    marc = marcdata.marc_tuple(REC_MX)
    assert marcdata.utils.material_type(marc) == "MX"
    assert marcdata.utils.fixed_length_tuple(marc) == \
        ("000724", "i", "1980", "2005", "xxu",
         ("     ", " ", "          "), "eng", " ", " ")
Example #18
0
def test_fixed_length_dict():
    fd = marcdata.utils.fixed_length_dict(marcdata.marc_tuple(REC1))
    assert fd["place_of_publication"] == "ilu"
    assert fd["language"] == "eng"