def test_tag_combination(capfd): doc = docman.Document() doc.tags = ["alpha", "beta"] doc, retval = _run(doc, args(clear=True, tags=["one", "two"])) assert retval == 0 assert doc.tags == ["one", "two"] assert capfd.readouterr() == ("one two\n", "")
def test_title_noarg(capfd): doc = docman.Document() doc.title = "some_title" doc, retval = _run(doc, args()) assert retval == 0 assert doc.title == "some_title" assert capfd.readouterr() == ("some_title\n", "")
def test_title_clear(capfd): doc = docman.Document() doc.title = "some title" doc, retval = _run(doc, args(clear=True)) assert retval == 0 assert doc.title is None assert capfd.readouterr() == ("\n", "")
def test_tag_clear(capfd): doc = docman.Document() doc.tags = ["alpha", "beta"] doc, retval = _run(doc, args(clear=True)) assert retval == 0 assert doc.tags == [] assert capfd.readouterr() == ("\n", "")
def test_tag_remove(capfd): doc = docman.Document() doc.tags = ["alpha", "beta"] doc, retval = _run(doc, args(remove=["beta", "gamma"])) assert retval == 0 assert doc.tags == ["alpha"] assert capfd.readouterr() == ("alpha\n", "")
def test_date_invalid(capfd): doc = docman.Document() assert doc.date is None doc, retval = _run(doc, args(date=["2021", "13", "01"])) assert retval == 1 assert doc is None assert capfd.readouterr() == ("Date must be in YYYY-MM-DD format.\n", "")
def test_date_multiple(capfd): doc = docman.Document() assert doc.date is None doc, retval = _run(doc, args(date=["2021", "01", "01"])) assert retval == 0 assert doc.date == date(2021, 1, 1) assert capfd.readouterr() == ("2021-01-01\n", "")
def test_title_set(capfd): doc = docman.Document() assert doc.title is None doc, retval = _run(doc, args(title=["Single Arg Title"])) assert retval == 0 assert doc.title == "Single_Arg_Title" assert capfd.readouterr() == ("Single_Arg_Title\n", "") doc, retval = _run(doc, args(title=["Multi", "Arg Title"])) assert retval == 0 assert doc.title == "Multi_Arg_Title" assert capfd.readouterr() == ("Multi_Arg_Title\n", "")
def get_default_doc(): doc = docman.Document() doc.tags = ["alpha", "omega"] doc.title = "some_title" doc.ocr = "this is some ocr" doc.input_files = ["some", "input", "files"] doc.date = dt.datetime.now() doc.pdf = "some pdf" doc.mode = "add" doc._id = "some id" return doc
def get_default_doc(): cmd_template = "echo scancmd {file}" doc = docman.Document() doc.wd = "/tmp/docman" doc.config = {"INTEGRATION": {"scan": cmd_template}} return doc