Skip to content

Commit

Permalink
Move test documents to text/test/data from widget tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Aug 22, 2023
1 parent f18d600 commit ffe6b5c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
5 changes: 3 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
recursive-include orangecontrib/text/datasets *.tab *.txt *.metadata
recursive-include orangecontrib/text/models *.ftz
recursive-include orangecontrib/text/sentiment *.txt
recursive-include orangecontrib/text/tests *.txt *.json *.pkl *.udpipe
recursive-include orangecontrib/text/tests *.txt *.json
recursive-include orangecontrib/text/tests/data *
recursive-include orangecontrib/text/tutorials *.ows
recursive-include orangecontrib/text/widgets/icons *.svg *.png *.ai
recursive-include orangecontrib/text/widgets/resources *.js *.css *.html
recursive-include orangecontrib/text/widgets/tests/data *.docx *.odt *.pdf *.txt *.conllu *.csv *.tab *.tab.metadata
recursive-include orangecontrib/text/widgets/tests/data *.txt *.conllu *.csv *.tab *.tab.metadata
include orangecontrib/text/widgets/tests/bow-test
recursive-include scripts *.sh *.py

Expand Down
Binary file not shown.
Binary file not shown.
30 changes: 20 additions & 10 deletions orangecontrib/text/widgets/tests/test_owimportdocuments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,49 @@
from orangecontrib.text.widgets.owimportdocuments import OWImportDocuments


DATA_PATH = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..", "tests", "data", "documents")
)


class TestOWImportDocuments(WidgetTest):
def setUp(self) -> None:
self.widget: OWImportDocuments = self.create_widget(OWImportDocuments)
path = os.path.join(os.path.dirname(__file__), "data/documents")
path = os.path.join(os.path.dirname(__file__), DATA_PATH)
self.widget.setCurrentPath(path)
self.widget.reload()
self.wait_until_finished()

def test_current_path(self):
path = os.path.join(os.path.dirname(__file__), "data/documents")
path = os.path.join(os.path.dirname(__file__), DATA_PATH)
self.assertEqual(path, self.widget.currentPath)

def test_no_skipped(self):
path = os.path.join(os.path.dirname(__file__), "data/documents", "good")
path = os.path.join(DATA_PATH, "good")
self.widget.setCurrentPath(path)
self.widget.reload()
self.wait_until_finished()
self.assertIsNone(self.get_output(self.widget.Outputs.skipped_documents))

def test_output(self):
output = self.get_output(self.widget.Outputs.data)
self.assertEqual(4, len(output))
self.assertEqual(5, len(output))
self.assertEqual(3, len(output.domain.metas))
names = output.get_column("name")
self.assertListEqual(
# ž in sample_text_ž must be unicode char 0x17E not decomposed
# 0x7A + 0x30C as it is in file name
["sample_docx", "sample_odt", "sample_pdf", "sample_txt_ž"],
[
"minimal-document",
"sample_docx",
"sample_odt",
"sample_pdf",
"sample_txt_ž",
],
sorted(names.tolist()),
)
texts = output.get_column("content")
# skip first document - it contains different text
texts = output.get_column("content")[1:]
self.assertListEqual(
# ž in sample_text_ž must be unicode char 0x17E not decomposed
# 0x7A + 0x30C as it is in file name
Expand Down Expand Up @@ -99,9 +111,7 @@ def test_conllu_cb(self):
self.assertEqual(len(corpus.domain.metas), 4)

def test_info_box(self):
self.assertEqual(
"4 documents, 1 skipped", self.widget.info_area.text()
)
self.assertEqual("5 documents, 1 skipped", self.widget.info_area.text())

# empty widget
self.widget: OWImportDocuments = self.create_widget(OWImportDocuments)
Expand All @@ -124,7 +134,7 @@ def tests_context(self):
# change default to something else to see if language is changed
self.widget.language = "Slovenian"

path = os.path.join(os.path.dirname(__file__), "data/documents", "good")
path = os.path.join(DATA_PATH, "good")
self.widget.setCurrentPath(path)
self.widget.reload()
self.wait_until_finished()
Expand Down

0 comments on commit ffe6b5c

Please sign in to comment.