Esempio n. 1
0
def test_read_components_from_rulefile_rn(tmp_path):
    """Fine for CSV file to have MS-Windows line endings (\r\n)."""
    os.chdir(tmp_path)
    Path(ROOTDIR_RULEFILE_NAME).write_text(TEST_RULES_CSVSTR_RN)
    expected = PYOBJ
    real = _read_components_from_rulefile(csvfile=ROOTDIR_RULEFILE_NAME)
    assert real == expected
Esempio n. 2
0
def test_read_components_from_rulefile_legacy(tmp_path):
    """Fine for CSV line to pad fields with spaces and leave field 5 blank."""
    os.chdir(tmp_path)
    Path(ROOTDIR_RULEFILE_NAME).write_text(TEST_RULES_CSVSTR_LEGACY)
    expected = PYOBJ_LEGACY
    real = _read_components_from_rulefile(csvfile=ROOTDIR_RULEFILE_NAME)
    assert real == expected
Esempio n. 3
0
def test_read_components_from_rulefile_header_ignored(tmp_path):
    """The CSV file may have a header line, though it will be ignored."""
    os.chdir(tmp_path)
    Path(ROOTDIR_RULEFILE_NAME).write_text(TEST_RULES_CSVSTR)
    expected = PYOBJ
    real = _read_components_from_rulefile(csvfile=ROOTDIR_RULEFILE_NAME)
    assert real == expected
Esempio n. 4
0
def test_read_components_from_rulefile(tmp_path):
    """Return True if CSV file has no header line because it will be ignored anyway."""
    os.chdir(tmp_path)
    Path(ROOTDIR_RULEFILE_NAME).write_text(TEST_RULES_CSVSTR)
    expected = PYOBJ
    real = _read_components_from_rulefile(csvfile=ROOTDIR_RULEFILE_NAME)
    assert real == expected
Esempio n. 5
0
def test_read_components_from_rulefile_not_found(tmp_path):
    """Raises NoRulefileError if specified CSV file is not found."""
    os.chdir(tmp_path)
    Path(".rules2").write_text(TEST_RULES_CSVSTR)
    with pytest.raises(SystemExit):
        _read_components_from_rulefile(csvfile=".rules3")
Esempio n. 6
0
def test_read_components_from_rulefile_rulefile_not_specified2(tmp_path):
    """Raises NoRulefileError if called specifying no argument at all."""
    with pytest.raises(SystemExit):
        _read_components_from_rulefile()
Esempio n. 7
0
def test_passed_csvfile_none(tmp_path):
    """Exits with NoRulefileError if passed 'csvfile' argument of None."""
    with pytest.raises(SystemExit):
        _read_components_from_rulefile(csvfile=None)