mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-04 14:15:59 +00:00
Convert unit tests to munit
This commit is contained in:
parent
8ff83656ce
commit
6a63694a3e
38
build.sbt
38
build.sbt
@ -45,12 +45,6 @@ val sharedSettings = Seq(
|
||||
(scalacOptions.value.filter(o => !o.contains("-Xlint") && !o.contains("-W")))
|
||||
) ++ scalafixSettings
|
||||
|
||||
val testSettings = Seq(
|
||||
testFrameworks += new TestFramework("minitest.runner.Framework"),
|
||||
libraryDependencies ++= Dependencies.miniTest ++ Dependencies.logging.map(_ % Test),
|
||||
Test / fork := true
|
||||
)
|
||||
|
||||
val testSettingsMUnit = Seq(
|
||||
libraryDependencies ++= Dependencies.munit.map(_ % Test),
|
||||
testFrameworks += new TestFramework("munit.Framework")
|
||||
@ -231,7 +225,7 @@ val common = project
|
||||
.in(file("modules/common"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-common",
|
||||
libraryDependencies ++=
|
||||
@ -249,7 +243,7 @@ val files = project
|
||||
.in(file("modules/files"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-files",
|
||||
libraryDependencies ++=
|
||||
@ -308,7 +302,7 @@ val store = project
|
||||
.in(file("modules/store"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-store",
|
||||
libraryDependencies ++=
|
||||
@ -330,7 +324,7 @@ val extract = project
|
||||
.in(file("modules/extract"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-extract",
|
||||
libraryDependencies ++=
|
||||
@ -347,7 +341,7 @@ val convert = project
|
||||
.in(file("modules/convert"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-convert",
|
||||
libraryDependencies ++=
|
||||
@ -361,7 +355,7 @@ val analysis = project
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.enablePlugins(NerModelsPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(NerModelsPlugin.nerClassifierSettings)
|
||||
.settings(
|
||||
name := "docspell-analysis",
|
||||
@ -375,7 +369,7 @@ val ftsclient = project
|
||||
.in(file("modules/fts-client"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-fts-client",
|
||||
libraryDependencies ++= Seq.empty
|
||||
@ -386,7 +380,7 @@ val ftssolr = project
|
||||
.in(file("modules/fts-solr"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-fts-solr",
|
||||
libraryDependencies ++=
|
||||
@ -402,7 +396,7 @@ val restapi = project
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.enablePlugins(OpenApiSchema)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(openapiScalaSettings)
|
||||
.settings(
|
||||
name := "docspell-restapi",
|
||||
@ -420,7 +414,7 @@ val joexapi = project
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.enablePlugins(OpenApiSchema)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(openapiScalaSettings)
|
||||
.settings(
|
||||
name := "docspell-joexapi",
|
||||
@ -438,7 +432,7 @@ val backend = project
|
||||
.in(file("modules/backend"))
|
||||
.disablePlugins(RevolverPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(
|
||||
name := "docspell-backend",
|
||||
libraryDependencies ++=
|
||||
@ -473,7 +467,7 @@ val joex = project
|
||||
.in(file("modules/joex"))
|
||||
.enablePlugins(BuildInfoPlugin, JavaServerAppPackaging, DebianPlugin, SystemdPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(debianSettings("docspell-joex"))
|
||||
.settings(buildInfoSettings)
|
||||
.settings(
|
||||
@ -512,7 +506,7 @@ val restserver = project
|
||||
.in(file("modules/restserver"))
|
||||
.enablePlugins(BuildInfoPlugin, JavaServerAppPackaging, DebianPlugin, SystemdPlugin)
|
||||
.settings(sharedSettings)
|
||||
.settings(testSettings)
|
||||
.settings(testSettingsMUnit)
|
||||
.settings(debianSettings("docspell-server"))
|
||||
.settings(buildInfoSettings)
|
||||
.settings(
|
||||
@ -740,7 +734,8 @@ def packageTools(logger: Logger, dir: File, version: String): Seq[File] = {
|
||||
wx / "icons" / "logo-96.png" -> "icons/logo-96.png",
|
||||
wx / "manifest.json" -> "manifest.json"
|
||||
),
|
||||
webext
|
||||
webext,
|
||||
None
|
||||
)
|
||||
|
||||
val excludes = Seq(wx, target)
|
||||
@ -757,7 +752,8 @@ def packageTools(logger: Logger, dir: File, version: String): Seq[File] = {
|
||||
wx / "native/app_manifest.json" -> s"docspell-tools-${version}/firefox/native/app_manifest.json",
|
||||
wx / "native/native.py" -> s"docspell-tools-${version}/firefox/native/native.py"
|
||||
) ++ files,
|
||||
archive
|
||||
archive,
|
||||
None
|
||||
)
|
||||
|
||||
Seq(archive)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.analysis.classifier
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import cats.effect._
|
||||
import scala.concurrent.ExecutionContext
|
||||
import java.nio.file.Paths
|
||||
@ -10,7 +10,7 @@ import fs2.Stream
|
||||
import cats.data.Kleisli
|
||||
import TextClassifier.Data
|
||||
|
||||
object StanfordTextClassifierSuite extends SimpleTestSuite {
|
||||
class StanfordTextClassifierSuite extends FunSuite {
|
||||
val logger = Logger.log4s[IO](org.log4s.getLogger)
|
||||
|
||||
implicit val CS = IO.contextShift(ExecutionContext.global)
|
||||
|
@ -1,9 +1,9 @@
|
||||
package docspell.analysis.contact
|
||||
|
||||
import docspell.common.{NerLabel, NerTag}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object ContactAnnotateSpec extends SimpleTestSuite {
|
||||
class ContactAnnotateSpec extends FunSuite {
|
||||
|
||||
test("find email") {
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package docspell.analysis.date
|
||||
|
||||
import docspell.files.TestFiles
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
import docspell.common._
|
||||
import java.time._
|
||||
|
||||
object DateFindSpec extends SimpleTestSuite {
|
||||
class DateFindSpec extends FunSuite {
|
||||
|
||||
test("find simple dates") {
|
||||
val expect = Vector(
|
||||
|
@ -2,19 +2,17 @@ package docspell.analysis.nlp
|
||||
|
||||
import docspell.analysis.Env
|
||||
import docspell.common.Language.NLPLanguage
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
import docspell.files.TestFiles
|
||||
import docspell.common._
|
||||
|
||||
object BaseCRFAnnotatorSuite extends SimpleTestSuite {
|
||||
class BaseCRFAnnotatorSuite extends FunSuite {
|
||||
|
||||
def annotate(language: NLPLanguage): String => Vector[NerLabel] =
|
||||
BasicCRFAnnotator.nerAnnotate(BasicCRFAnnotator.Cache.getAnnotator(language))
|
||||
|
||||
test("find english ner labels") {
|
||||
if (Env.isCI) {
|
||||
ignore("Test ignored on travis.")
|
||||
}
|
||||
assume(!Env.isCI, "Test ignored on travis.")
|
||||
|
||||
val labels = annotate(Language.English)(TestFiles.letterENText)
|
||||
val expect = Vector(
|
||||
@ -52,9 +50,7 @@ object BaseCRFAnnotatorSuite extends SimpleTestSuite {
|
||||
}
|
||||
|
||||
test("find german ner labels") {
|
||||
if (Env.isCI) {
|
||||
ignore("Test ignored on travis.")
|
||||
}
|
||||
assume(!Env.isCI, "Test ignored on travis.")
|
||||
|
||||
val labels = annotate(Language.German)(TestFiles.letterDEText)
|
||||
val expect = Vector(
|
||||
|
@ -4,22 +4,20 @@ import java.nio.file.Paths
|
||||
|
||||
import cats.effect.IO
|
||||
import docspell.analysis.Env
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
import docspell.files.TestFiles
|
||||
import docspell.common._
|
||||
import docspell.common.syntax.FileSyntax._
|
||||
import edu.stanford.nlp.pipeline.StanfordCoreNLP
|
||||
|
||||
object StanfordNerAnnotatorSuite extends SimpleTestSuite {
|
||||
class StanfordNerAnnotatorSuite extends FunSuite {
|
||||
lazy val germanClassifier =
|
||||
new StanfordCoreNLP(Properties.nerGerman(None, false))
|
||||
lazy val englishClassifier =
|
||||
new StanfordCoreNLP(Properties.nerEnglish(None))
|
||||
|
||||
test("find english ner labels") {
|
||||
if (Env.isCI) {
|
||||
ignore("Test ignored on travis.")
|
||||
}
|
||||
assume(!Env.isCI, "Test ignored on travis.")
|
||||
|
||||
val labels =
|
||||
StanfordNerAnnotator.nerAnnotate(englishClassifier, TestFiles.letterENText)
|
||||
@ -58,9 +56,7 @@ object StanfordNerAnnotatorSuite extends SimpleTestSuite {
|
||||
}
|
||||
|
||||
test("find german ner labels") {
|
||||
if (Env.isCI) {
|
||||
ignore("Test ignored on travis.")
|
||||
}
|
||||
assume(!Env.isCI, "Test ignored on travis.")
|
||||
|
||||
val labels =
|
||||
StanfordNerAnnotator.nerAnnotate(germanClassifier, TestFiles.letterDEText)
|
||||
@ -83,9 +79,7 @@ object StanfordNerAnnotatorSuite extends SimpleTestSuite {
|
||||
}
|
||||
|
||||
test("regexner-only annotator") {
|
||||
if (Env.isCI) {
|
||||
ignore("Test ignored on travis.")
|
||||
}
|
||||
assume(!Env.isCI, "Test ignored on travis.")
|
||||
|
||||
val regexNerContent =
|
||||
s"""(?i)volantino ag${"\t"}ORGANIZATION${"\t"}LOCATION,PERSON,MISC${"\t"}3
|
||||
|
@ -1,8 +1,8 @@
|
||||
package docspell.analysis.split
|
||||
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object TestSplitterSpec extends SimpleTestSuite {
|
||||
class TestSplitterSpec extends FunSuite {
|
||||
|
||||
test("simple splitting") {
|
||||
val text = """hiermit kündige ich meine Mitgliedschaft in der Kranken- und
|
||||
|
@ -1,8 +1,8 @@
|
||||
package docspell.common
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
|
||||
object FileNameTest extends SimpleTestSuite {
|
||||
class FileNameTest extends FunSuite {
|
||||
|
||||
test("make filename") {
|
||||
val data = List(
|
||||
|
@ -1,9 +1,9 @@
|
||||
package docspell.common
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import Glob._
|
||||
|
||||
object GlobTest extends SimpleTestSuite {
|
||||
class GlobTest extends FunSuite {
|
||||
|
||||
test("literals") {
|
||||
assert(Glob.pattern(Pattern(Segment(Token.Literal("hello")))).matches(true)("hello"))
|
||||
|
@ -1,10 +1,10 @@
|
||||
package docspell.common
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import cats.data.NonEmptyList
|
||||
import docspell.common.MetaProposal.Candidate
|
||||
|
||||
object MetaProposalListTest extends SimpleTestSuite {
|
||||
class MetaProposalListTest extends FunSuite {
|
||||
|
||||
test("flatten retains order of candidates") {
|
||||
val cand1 = Candidate(IdRef(Ident.unsafe("123"), "name"), Set.empty)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package docspell.common
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
|
||||
object NerLabelSpanTest extends SimpleTestSuite {
|
||||
class NerLabelSpanTest extends FunSuite {
|
||||
|
||||
test("build") {
|
||||
val labels = List(
|
||||
|
@ -11,10 +11,10 @@ import docspell.convert.ConversionResult.Handler
|
||||
import docspell.convert.extern.{TesseractConfig, UnoconvConfig, WkHtmlPdfConfig}
|
||||
import docspell.convert.flexmark.MarkdownConfig
|
||||
import docspell.files.{ExampleFiles, TestFiles}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
import docspell.convert.extern.OcrMyPdfConfig
|
||||
|
||||
object ConversionTest extends SimpleTestSuite with FileChecks {
|
||||
class ConversionTest extends FunSuite with FileChecks {
|
||||
val blocker = TestFiles.blocker
|
||||
implicit val CS = TestFiles.CS
|
||||
|
||||
@ -101,59 +101,58 @@ object ConversionTest extends SimpleTestSuite with FileChecks {
|
||||
)
|
||||
|
||||
test("convert to pdf") {
|
||||
if (!commandsExist) ignore("At least one of the conversion programs not found")
|
||||
else
|
||||
File
|
||||
.withTempDir[IO](target, "convpdf")
|
||||
.use { dir =>
|
||||
conversion.use { conv =>
|
||||
def check(n: Long): Handler[IO, Unit] =
|
||||
storePdfHandler(dir.resolve(s"test-$n.pdf")).map { p =>
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
}
|
||||
assume(commandsExist, "At least one of the conversion programs not found")
|
||||
|
||||
runConversion(pdfOnly, check, conv).compile.drain
|
||||
}
|
||||
File
|
||||
.withTempDir[IO](target, "convpdf")
|
||||
.use { dir =>
|
||||
conversion.use { conv =>
|
||||
def check(n: Long): Handler[IO, Unit] =
|
||||
storePdfHandler(dir.resolve(s"test-$n.pdf")).map { p =>
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
}
|
||||
|
||||
runConversion(pdfOnly, check, conv).compile.drain
|
||||
}
|
||||
.unsafeRunSync()
|
||||
}
|
||||
.unsafeRunSync()
|
||||
}
|
||||
|
||||
test("convert image to pdf and txt") {
|
||||
if (!commandsExist) ignore("At least one of the conversion programs not found")
|
||||
else
|
||||
File
|
||||
.withTempDir[IO](target, "convimgpdf")
|
||||
.use { dir =>
|
||||
conversion.use { conv =>
|
||||
def check(n: Long): Handler[IO, Unit] =
|
||||
storePdfTxtHandler(dir.resolve(s"test-$n.pdf"), dir.resolve(s"test-$n.txt"))
|
||||
.map { case (p, t) =>
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
assert(t.isNonEmpty && t.isPlainText)
|
||||
}
|
||||
assume(commandsExist, "At least one of the conversion programs not found")
|
||||
File
|
||||
.withTempDir[IO](target, "convimgpdf")
|
||||
.use { dir =>
|
||||
conversion.use { conv =>
|
||||
def check(n: Long): Handler[IO, Unit] =
|
||||
storePdfTxtHandler(dir.resolve(s"test-$n.pdf"), dir.resolve(s"test-$n.txt"))
|
||||
.map { case (p, t) =>
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
assert(t.isNonEmpty && t.isPlainText)
|
||||
}
|
||||
|
||||
runConversion(pdfAndTxt, check, conv).compile.drain
|
||||
}
|
||||
runConversion(pdfAndTxt, check, conv).compile.drain
|
||||
}
|
||||
.unsafeRunSync()
|
||||
}
|
||||
.unsafeRunSync()
|
||||
}
|
||||
|
||||
test("do not convert image bombs") {
|
||||
if (!commandsExist) ignore("At least one of the conversion programs not found")
|
||||
else
|
||||
conversion
|
||||
.use { conv =>
|
||||
def check: Handler[IO, Unit] =
|
||||
Kleisli({
|
||||
case ConversionResult.InputMalformed(_, _) =>
|
||||
().pure[IO]
|
||||
case cr =>
|
||||
IO.raiseError(new Exception(s"Unexpected result: $cr"))
|
||||
})
|
||||
assume(commandsExist, "At least one of the conversion programs not found")
|
||||
|
||||
runConversion(bombs, _ => check, conv).compile.drain
|
||||
}
|
||||
.unsafeRunSync()
|
||||
conversion
|
||||
.use { conv =>
|
||||
def check: Handler[IO, Unit] =
|
||||
Kleisli({
|
||||
case ConversionResult.InputMalformed(_, _) =>
|
||||
().pure[IO]
|
||||
case cr =>
|
||||
IO.raiseError(new Exception(s"Unexpected result: $cr"))
|
||||
})
|
||||
|
||||
runConversion(bombs, _ => check, conv).compile.drain
|
||||
}
|
||||
.unsafeRunSync()
|
||||
}
|
||||
|
||||
def runConversion[A](
|
||||
|
@ -6,10 +6,10 @@ import cats.effect._
|
||||
import docspell.common._
|
||||
import docspell.convert._
|
||||
import docspell.files.{ExampleFiles, TestFiles}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
object ExternConvTest extends SimpleTestSuite with FileChecks {
|
||||
class ExternConvTest extends FunSuite with FileChecks {
|
||||
val blocker = TestFiles.blocker
|
||||
implicit val CS = TestFiles.CS
|
||||
val utf8 = StandardCharsets.UTF_8
|
||||
@ -22,26 +22,24 @@ object ExternConvTest extends SimpleTestSuite with FileChecks {
|
||||
Seq("-s", "A4", "--encoding", "UTF-8", "-", "{{outfile}}"),
|
||||
Duration.seconds(20)
|
||||
)
|
||||
assume(commandExists(cfg.program), s"Command ${cfg.program} not found. Ignore tests.")
|
||||
File
|
||||
.withTempDir[IO](target, "wkhtmltopdf")
|
||||
.use(dir =>
|
||||
IO {
|
||||
val wkCfg = WkHtmlPdfConfig(cfg, target)
|
||||
val p =
|
||||
WkHtmlPdf
|
||||
.toPDF[IO, Path](wkCfg, 8192, utf8, SanitizeHtml.none, blocker, logger)(
|
||||
ExampleFiles.letter_de_html.readURL[IO](8192, blocker),
|
||||
storePdfHandler(dir.resolve("test.pdf"))
|
||||
)
|
||||
.unsafeRunSync()
|
||||
|
||||
if (!commandExists(cfg.program)) ignore(s"Command ${cfg.program} not found")
|
||||
else
|
||||
File
|
||||
.withTempDir[IO](target, "wkhtmltopdf")
|
||||
.use(dir =>
|
||||
IO {
|
||||
val wkCfg = WkHtmlPdfConfig(cfg, target)
|
||||
val p =
|
||||
WkHtmlPdf
|
||||
.toPDF[IO, Path](wkCfg, 8192, utf8, SanitizeHtml.none, blocker, logger)(
|
||||
ExampleFiles.letter_de_html.readURL[IO](8192, blocker),
|
||||
storePdfHandler(dir.resolve("test.pdf"))
|
||||
)
|
||||
.unsafeRunSync()
|
||||
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
}
|
||||
)
|
||||
.unsafeRunSync()
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
}
|
||||
)
|
||||
.unsafeRunSync()
|
||||
}
|
||||
|
||||
test("convert office to pdf") {
|
||||
@ -51,25 +49,24 @@ object ExternConvTest extends SimpleTestSuite with FileChecks {
|
||||
Duration.seconds(20)
|
||||
)
|
||||
|
||||
if (!commandExists(cfg.program)) ignore(s"Command ${cfg.program} not found")
|
||||
else
|
||||
File
|
||||
.withTempDir[IO](target, "unoconv")
|
||||
.use(dir =>
|
||||
IO {
|
||||
val ucCfg = UnoconvConfig(cfg, target)
|
||||
val p =
|
||||
Unoconv
|
||||
.toPDF[IO, Path](ucCfg, 8192, blocker, logger)(
|
||||
ExampleFiles.examples_sample_docx.readURL[IO](8192, blocker),
|
||||
storePdfHandler(dir.resolve("test.pdf"))
|
||||
)
|
||||
.unsafeRunSync()
|
||||
assume(commandExists(cfg.program), s"Command ${cfg.program} not found. Ignore tests.")
|
||||
File
|
||||
.withTempDir[IO](target, "unoconv")
|
||||
.use(dir =>
|
||||
IO {
|
||||
val ucCfg = UnoconvConfig(cfg, target)
|
||||
val p =
|
||||
Unoconv
|
||||
.toPDF[IO, Path](ucCfg, 8192, blocker, logger)(
|
||||
ExampleFiles.examples_sample_docx.readURL[IO](8192, blocker),
|
||||
storePdfHandler(dir.resolve("test.pdf"))
|
||||
)
|
||||
.unsafeRunSync()
|
||||
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
}
|
||||
)
|
||||
.unsafeRunSync()
|
||||
assert(p.isNonEmpty && p.isPDF)
|
||||
}
|
||||
)
|
||||
.unsafeRunSync()
|
||||
}
|
||||
|
||||
test("convert image to pdf") {
|
||||
@ -78,27 +75,25 @@ object ExternConvTest extends SimpleTestSuite with FileChecks {
|
||||
Seq("{{infile}}", "out", "-l", "deu", "pdf", "txt"),
|
||||
Duration.seconds(20)
|
||||
)
|
||||
assume(commandExists(cfg.program), s"Command ${cfg.program} not found")
|
||||
File
|
||||
.withTempDir[IO](target, "tesseract")
|
||||
.use(dir =>
|
||||
IO {
|
||||
val tessCfg = TesseractConfig(cfg, target)
|
||||
val (pdf, txt) =
|
||||
Tesseract
|
||||
.toPDF[IO, (Path, Path)](tessCfg, Language.German, 8192, blocker, logger)(
|
||||
ExampleFiles.camera_letter_en_jpg.readURL[IO](8192, blocker),
|
||||
storePdfTxtHandler(dir.resolve("test.pdf"), dir.resolve("test.txt"))
|
||||
)
|
||||
.unsafeRunSync()
|
||||
|
||||
if (!commandExists(cfg.program)) ignore(s"Command ${cfg.program} not found")
|
||||
else
|
||||
File
|
||||
.withTempDir[IO](target, "tesseract")
|
||||
.use(dir =>
|
||||
IO {
|
||||
val tessCfg = TesseractConfig(cfg, target)
|
||||
val (pdf, txt) =
|
||||
Tesseract
|
||||
.toPDF[IO, (Path, Path)](tessCfg, Language.German, 8192, blocker, logger)(
|
||||
ExampleFiles.camera_letter_en_jpg.readURL[IO](8192, blocker),
|
||||
storePdfTxtHandler(dir.resolve("test.pdf"), dir.resolve("test.txt"))
|
||||
)
|
||||
.unsafeRunSync()
|
||||
|
||||
assert(pdf.isNonEmpty && pdf.isPDF)
|
||||
assert(txt.isNonEmpty && txt.isPlainText)
|
||||
}
|
||||
)
|
||||
.unsafeRunSync()
|
||||
assert(pdf.isNonEmpty && pdf.isPDF)
|
||||
assert(txt.isNonEmpty && txt.isPlainText)
|
||||
}
|
||||
)
|
||||
.unsafeRunSync()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,15 +3,14 @@ package docspell.extract.ocr
|
||||
import cats.effect.IO
|
||||
import docspell.common.Logger
|
||||
import docspell.files.TestFiles
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object TextExtractionSuite extends SimpleTestSuite {
|
||||
class TextExtractionSuite extends FunSuite {
|
||||
import TestFiles._
|
||||
|
||||
val logger = Logger.log4s[IO](org.log4s.getLogger)
|
||||
|
||||
test("extract english pdf") {
|
||||
ignore()
|
||||
test("extract english pdf".ignore) {
|
||||
val text = TextExtract
|
||||
.extract[IO](letterSourceEN, blocker, logger, "eng", OcrConfig.default)
|
||||
.compile
|
||||
@ -20,8 +19,7 @@ object TextExtractionSuite extends SimpleTestSuite {
|
||||
println(text)
|
||||
}
|
||||
|
||||
test("extract german pdf") {
|
||||
ignore()
|
||||
test("extract german pdf".ignore) {
|
||||
val expect = TestFiles.letterDEText
|
||||
val extract = TextExtract
|
||||
.extract[IO](letterSourceDE, blocker, logger, "deu", OcrConfig.default)
|
||||
|
@ -2,9 +2,9 @@ package docspell.extract.odf
|
||||
|
||||
import cats.effect._
|
||||
import docspell.files.{ExampleFiles, TestFiles}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object OdfExtractTest extends SimpleTestSuite {
|
||||
class OdfExtractTest extends FunSuite {
|
||||
val blocker = TestFiles.blocker
|
||||
implicit val CS = TestFiles.CS
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package docspell.extract.pdfbox
|
||||
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object PdfMetaDataTest extends SimpleTestSuite {
|
||||
class PdfMetaDataTest extends FunSuite {
|
||||
|
||||
test("split keywords on comma") {
|
||||
val md = PdfMetaData.empty.copy(keywords = Some("a,b, c"))
|
||||
|
@ -2,9 +2,9 @@ package docspell.extract.pdfbox
|
||||
|
||||
import cats.effect._
|
||||
import docspell.files.{ExampleFiles, TestFiles}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object PdfboxExtractTest extends SimpleTestSuite {
|
||||
class PdfboxExtractTest extends FunSuite {
|
||||
val blocker = TestFiles.blocker
|
||||
implicit val CS = TestFiles.CS
|
||||
|
||||
|
@ -2,11 +2,11 @@ package docspell.extract.pdfbox
|
||||
|
||||
import cats.effect._
|
||||
import docspell.files.{ExampleFiles, TestFiles}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
import java.nio.file.Path
|
||||
import fs2.Stream
|
||||
|
||||
object PdfboxPreviewTest extends SimpleTestSuite {
|
||||
class PdfboxPreviewTest extends FunSuite {
|
||||
val blocker = TestFiles.blocker
|
||||
implicit val CS = TestFiles.CS
|
||||
|
||||
|
@ -3,9 +3,9 @@ package docspell.extract.poi
|
||||
import cats.effect._
|
||||
import docspell.common.MimeTypeHint
|
||||
import docspell.files.{ExampleFiles, TestFiles}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object PoiExtractTest extends SimpleTestSuite {
|
||||
class PoiExtractTest extends FunSuite {
|
||||
val blocker = TestFiles.blocker
|
||||
implicit val CS = TestFiles.CS
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package docspell.extract.rtf
|
||||
|
||||
import docspell.files.ExampleFiles
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object RtfExtractTest extends SimpleTestSuite {
|
||||
class RtfExtractTest extends FunSuite {
|
||||
|
||||
test("extract text from rtf using java input-stream") {
|
||||
val file = ExampleFiles.examples_sample_rtf
|
||||
|
@ -2,12 +2,12 @@ package docspell.files
|
||||
|
||||
import cats.implicits._
|
||||
import cats.effect.{Blocker, IO}
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
import scala.util.Using
|
||||
|
||||
object ImageSizeTest extends SimpleTestSuite {
|
||||
class ImageSizeTest extends FunSuite {
|
||||
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
|
||||
implicit val CS = IO.contextShift(ExecutionContext.global)
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package docspell.files
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
import scala.concurrent.ExecutionContext
|
||||
import docspell.common.Glob
|
||||
|
||||
object ZipTest extends SimpleTestSuite {
|
||||
class ZipTest extends FunSuite {
|
||||
|
||||
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
|
||||
implicit val CS = IO.contextShift(ExecutionContext.global)
|
||||
|
@ -1,10 +1,10 @@
|
||||
package docspell.joex.analysis
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import NerFile.Pattern
|
||||
import java.{util => ju}
|
||||
|
||||
object NerFileTest extends SimpleTestSuite {
|
||||
class NerFileTest extends FunSuite {
|
||||
|
||||
test("create valid case insensitive patterns") {
|
||||
val names = List(
|
||||
|
@ -1,9 +1,9 @@
|
||||
package docspell.joex.scheduler
|
||||
|
||||
import docspell.common.Priority
|
||||
import minitest.SimpleTestSuite
|
||||
import munit._
|
||||
|
||||
object CountingSchemeSpec extends SimpleTestSuite {
|
||||
class CountingSchemeSpec extends FunSuite {
|
||||
|
||||
test("counting") {
|
||||
val cs = CountingScheme(2, 1)
|
||||
|
@ -3,14 +3,14 @@ package docspell.store.generator
|
||||
import java.time.LocalDate
|
||||
|
||||
import docspell.store.records._
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.common._
|
||||
import docspell.query.ItemQueryParser
|
||||
import docspell.store.queries.AttachCountTable
|
||||
import docspell.store.qb.DSL._
|
||||
import docspell.store.qb.generator.{ItemQueryGenerator, Tables}
|
||||
|
||||
object ItemQueryGeneratorTest extends SimpleTestSuite {
|
||||
class ItemQueryGeneratorTest extends FunSuite {
|
||||
import docspell.store.impl.DoobieMeta._
|
||||
|
||||
val tables = Tables(
|
||||
|
@ -1,10 +1,10 @@
|
||||
package docspell.store.qb
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.store.qb.model._
|
||||
import docspell.store.qb.DSL._
|
||||
|
||||
object QueryBuilderTest extends SimpleTestSuite {
|
||||
class QueryBuilderTest extends FunSuite {
|
||||
|
||||
test("simple") {
|
||||
val c = CourseRecord.as("c")
|
||||
|
@ -1,11 +1,11 @@
|
||||
package docspell.store.qb.impl
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.store.qb._
|
||||
import docspell.store.qb.DSL._
|
||||
import docspell.store.qb.model.{CourseRecord, PersonRecord}
|
||||
|
||||
object ConditionBuilderTest extends SimpleTestSuite {
|
||||
class ConditionBuilderTest extends FunSuite {
|
||||
|
||||
val c = CourseRecord.as("c")
|
||||
val p = PersonRecord.as("p")
|
||||
|
@ -1,11 +1,11 @@
|
||||
package docspell.store.qb.impl
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.store.qb._
|
||||
import docspell.store.qb.DSL._
|
||||
import docspell.store.qb.model.{CourseRecord, PersonRecord}
|
||||
|
||||
object DSLTest extends SimpleTestSuite {
|
||||
class DSLTest extends FunSuite {
|
||||
|
||||
val course = CourseRecord.as("c")
|
||||
val person = PersonRecord.as("p")
|
||||
|
@ -1,11 +1,11 @@
|
||||
package docspell.store.qb.impl
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
import docspell.store.qb._
|
||||
import docspell.store.qb.model._
|
||||
import docspell.store.qb.DSL._
|
||||
|
||||
object SelectBuilderTest extends SimpleTestSuite {
|
||||
class SelectBuilderTest extends FunSuite {
|
||||
|
||||
test("basic fragment") {
|
||||
val c = CourseRecord.as("c")
|
||||
|
@ -1,8 +1,8 @@
|
||||
package docspell.store.queries
|
||||
|
||||
import minitest._
|
||||
import munit._
|
||||
|
||||
object QueryWildcardTest extends SimpleTestSuite {
|
||||
class QueryWildcardTest extends FunSuite {
|
||||
|
||||
test("replace prefix") {
|
||||
assertEquals("%name", QueryWildcard("*name"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user