Refactored unit tests
@ -1,13 +0,0 @@
|
||||
from unittest import TestCase
|
||||
from parsing import DocxParser
|
||||
|
||||
|
||||
class DocxParserTest(TestCase):
|
||||
|
||||
def test_parse_content(self):
|
||||
|
||||
parser = DocxParser([], 1000, "test_files/")
|
||||
|
||||
info = parser.parse("test_files/docx1.docx")
|
||||
|
||||
self.assertEqual(len(info["content"]), 1000)
|
@ -1,13 +0,0 @@
|
||||
from unittest import TestCase
|
||||
from parsing import EbookParser
|
||||
|
||||
|
||||
class EbookParserTest(TestCase):
|
||||
|
||||
def test_parse_content(self):
|
||||
|
||||
parser = EbookParser([], 1000, "test_files/")
|
||||
|
||||
info = parser.parse("test_files/epub1.epub")
|
||||
|
||||
self.assertEqual(len(info["content"]), 1000)
|
@ -1,37 +0,0 @@
|
||||
from unittest import TestCase
|
||||
from parsing import FontParser
|
||||
|
||||
|
||||
class FontParserTest(TestCase):
|
||||
|
||||
def test_parse_name_trueType(self):
|
||||
|
||||
parser = FontParser([], "test_files/")
|
||||
|
||||
info = parser.parse("test_files/truetype1.ttf")
|
||||
|
||||
self.assertEqual(info["content"], "Liberation Mono Bold")
|
||||
|
||||
def test_parse_name_openType(self):
|
||||
|
||||
parser = FontParser([], "test_files/")
|
||||
|
||||
info = parser.parse("test_files/opentype1.otf")
|
||||
|
||||
self.assertEqual(info["content"], "Linux Biolinum Keyboard O")
|
||||
|
||||
def test_parse_name_woff(self):
|
||||
|
||||
parser = FontParser([], "test_files/")
|
||||
|
||||
info = parser.parse("test_files/woff.woff")
|
||||
|
||||
self.assertEqual(info["content"], "Heart of Gold")
|
||||
|
||||
def test_parse_name_woff2(self):
|
||||
|
||||
parser = FontParser([], "test_files/")
|
||||
|
||||
info = parser.parse("test_files/woff2.woff2")
|
||||
|
||||
self.assertEqual(info["content"], "Heart of Gold")
|
@ -1,23 +0,0 @@
|
||||
from parsing import ContentMimeGuesser, ExtensionMimeGuesser
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
class MimeGuesserTest(TestCase):
|
||||
|
||||
def test_content_guesser(self):
|
||||
|
||||
guesser = ContentMimeGuesser()
|
||||
|
||||
self.assertEqual("text/x-shellscript", guesser.guess_mime("test_folder/test_utf8.sh"))
|
||||
self.assertEqual("text/plain", guesser.guess_mime("test_folder/more_books.json"))
|
||||
self.assertEqual("application/java-archive", guesser.guess_mime("test_folder/post.jar"))
|
||||
self.assertEqual("image/jpeg", guesser.guess_mime("test_folder/sample_1.jpg"))
|
||||
|
||||
def test_extension_guesser(self):
|
||||
|
||||
guesser = ExtensionMimeGuesser()
|
||||
|
||||
self.assertEqual("text/x-sh", guesser.guess_mime("test_folder/test_utf8.sh"))
|
||||
self.assertEqual("application/json", guesser.guess_mime("test_folder/more_books.json"))
|
||||
self.assertEqual("application/java-archive", guesser.guess_mime("test_folder/post.jar"))
|
||||
self.assertEqual("image/jpeg", guesser.guess_mime("test_folder/sample_1.jpg"))
|
0
test/__init__.py
Normal file
@ -2,6 +2,9 @@ from unittest import TestCase
|
||||
|
||||
from parsing import GenericFileParser, Sha1CheckSumCalculator, ExtensionMimeGuesser
|
||||
from crawler import Crawler
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class CrawlerTest(TestCase):
|
||||
@ -10,7 +13,7 @@ class CrawlerTest(TestCase):
|
||||
|
||||
c = Crawler([GenericFileParser([Sha1CheckSumCalculator()], "test_files/")])
|
||||
|
||||
c.crawl("./test_folder")
|
||||
c.crawl(dir_name + "/test_folder")
|
||||
|
||||
self.assertEqual(len(c.documents), 31)
|
||||
|
||||
@ -18,12 +21,12 @@ class CrawlerTest(TestCase):
|
||||
|
||||
c = Crawler([])
|
||||
|
||||
self.assertEqual(c.countFiles("test_folder"), 31)
|
||||
self.assertEqual(c.countFiles(dir_name + "/test_folder"), 31)
|
||||
|
||||
def test_path(self):
|
||||
|
||||
c = Crawler([GenericFileParser([], "./test_folder")])
|
||||
c.crawl("./test_folder")
|
||||
c = Crawler([GenericFileParser([], dir_name + "/test_folder")])
|
||||
c.crawl(dir_name + "/test_folder")
|
||||
|
||||
file_count_in_sub2 = 0
|
||||
|
16
test/test_DocxParser.py
Normal file
@ -0,0 +1,16 @@
|
||||
from unittest import TestCase
|
||||
from parsing import DocxParser
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class DocxParserTest(TestCase):
|
||||
|
||||
def test_parse_content(self):
|
||||
|
||||
parser = DocxParser([], 1000, dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse(dir_name + "/test_files/docx1.docx")
|
||||
|
||||
self.assertEqual(len(info["content"]), 1000)
|
16
test/test_EbookParser.py
Normal file
@ -0,0 +1,16 @@
|
||||
from unittest import TestCase
|
||||
from parsing import EbookParser
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class EbookParserTest(TestCase):
|
||||
|
||||
def test_parse_content(self):
|
||||
|
||||
parser = EbookParser([], 1000, dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse(dir_name + "/test_files/epub1.epub")
|
||||
|
||||
self.assertEqual(len(info["content"]), 1000)
|
40
test/test_FontParser.py
Normal file
@ -0,0 +1,40 @@
|
||||
from unittest import TestCase
|
||||
from parsing import FontParser
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class FontParserTest(TestCase):
|
||||
|
||||
def test_parse_name_trueType(self):
|
||||
|
||||
parser = FontParser([], dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse(dir_name + "/test_files/truetype1.ttf")
|
||||
|
||||
self.assertEqual(info["content"], "Liberation Mono Bold")
|
||||
|
||||
def test_parse_name_openType(self):
|
||||
|
||||
parser = FontParser([], dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse(dir_name + "/test_files/opentype1.otf")
|
||||
|
||||
self.assertEqual(info["content"], "Linux Biolinum Keyboard O")
|
||||
|
||||
def test_parse_name_woff(self):
|
||||
|
||||
parser = FontParser([], dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse(dir_name + "/test_files/woff.woff")
|
||||
|
||||
self.assertEqual(info["content"], "Heart of Gold")
|
||||
|
||||
def test_parse_name_woff2(self):
|
||||
|
||||
parser = FontParser([], dir_name + "test_files/")
|
||||
|
||||
info = parser.parse(dir_name + "/test_files/woff2.woff2")
|
||||
|
||||
self.assertEqual(info["content"], "Heart of Gold")
|
@ -2,19 +2,23 @@ from unittest import TestCase
|
||||
from storage import LocalStorage, Directory, DuplicateDirectoryException, User, DuplicateUserException, Option, Task
|
||||
import os
|
||||
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class LocalStorageTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
if os.path.exists("test_database.db"):
|
||||
os.remove("test_database.db")
|
||||
if os.path.exists(dir_name + "/test_database.db"):
|
||||
os.remove(dir_name + "/test_database.db")
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s.init_db("../database.sql")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
s.init_db(dir_name + "/../database.sql")
|
||||
|
||||
def test_save_and_retrieve_dir(self):
|
||||
|
||||
storage = LocalStorage("test_database.db")
|
||||
storage = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
|
||||
@ -27,13 +31,13 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_save_and_retrieve_dir_persistent(self):
|
||||
|
||||
s1 = LocalStorage("test_database.db")
|
||||
s1 = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
|
||||
dir_id = s1.save_directory(d)
|
||||
|
||||
s2 = LocalStorage("test_database.db")
|
||||
s2 = LocalStorage(dir_name + "/test_database.db")
|
||||
self.assertEqual(s2.dirs()[dir_id].enabled, True)
|
||||
|
||||
self.assertEqual(s2.dirs()[dir_id].options[0].key, "key1")
|
||||
@ -42,7 +46,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_reject_duplicate_path(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d1 = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
d2 = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
@ -53,7 +57,7 @@ class LocalStorageTest(TestCase):
|
||||
s.save_directory(d2)
|
||||
|
||||
def test_remove_dir(self):
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val3")], "An excellent name")
|
||||
dir_id = s.save_directory(d)
|
||||
@ -65,7 +69,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_save_and_retrieve_user(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
u = User("bob", b"anHashedPassword", True)
|
||||
|
||||
@ -76,14 +80,14 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_return_none_with_unknown_user(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
with self.assertRaises(KeyError) as e:
|
||||
_ = s.users()["unknown_user"]
|
||||
|
||||
def test_auth_user(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
u = User("bob", b'$2b$10$RakMb.3n/tl76sK7iVahJuklNYkR7f2Y4dsf73tPANwYBkp4VuJ7.', True)
|
||||
|
||||
@ -96,7 +100,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_reject_duplicate_user(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
u1 = User("user1", b"anHashedPassword", True)
|
||||
u2 = User("user1", b"anotherHashedPassword", True)
|
||||
@ -107,7 +111,7 @@ class LocalStorageTest(TestCase):
|
||||
s.save_user(u2)
|
||||
|
||||
def test_update_user(self):
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
u = User("neil", b"anHashedPassword", True)
|
||||
|
||||
@ -120,7 +124,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_remove_user(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
u = User("martin", b"anHashedPassword", True)
|
||||
s.save_user(u)
|
||||
@ -132,7 +136,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_update_directory(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
|
||||
@ -145,7 +149,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
s.update_directory(d)
|
||||
|
||||
s2 = LocalStorage("test_database.db")
|
||||
s2 = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
self.assertEqual(s2.dirs()[dir_id].name, "A modified name")
|
||||
self.assertEqual(len(s2.dirs()[dir_id].options), 2)
|
||||
@ -154,7 +158,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_save_option(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
dir_id = s.save_directory(d)
|
||||
@ -168,7 +172,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_del_option(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
dir_id = s.save_directory(d)
|
||||
@ -181,7 +185,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_update_option(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
d = Directory("/some/directory", True, [Option("key1", "val1"), Option("key2", "val2")], "An excellent name")
|
||||
dir_id = s.save_directory(d)
|
||||
@ -192,7 +196,7 @@ class LocalStorageTest(TestCase):
|
||||
|
||||
def test_save_task(self):
|
||||
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
dir_id = s.save_directory(Directory("/some/dir", True, [], "my dir"))
|
||||
task_id = s.save_task(Task(0, dir_id))
|
||||
@ -201,12 +205,12 @@ class LocalStorageTest(TestCase):
|
||||
self.assertEqual(task_id, 1)
|
||||
|
||||
def test_del_task(self):
|
||||
s = LocalStorage("test_database.db")
|
||||
s = LocalStorage(dir_name + "/test_database.db")
|
||||
|
||||
dir_id = s.save_directory(Directory("/some/dir", True, [], "my dir"))
|
||||
task_id = s.save_task(Task(0, dir_id))
|
||||
|
||||
s2 = LocalStorage("test_database.db")
|
||||
s2 = LocalStorage(dir_name + "/test_database.db")
|
||||
s2.tasks()
|
||||
s2.del_task(task_id)
|
||||
|
@ -1,22 +1,25 @@
|
||||
from unittest import TestCase
|
||||
from parsing import MediaFileParser
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MediaFileParserTest(TestCase):
|
||||
|
||||
def test_audio_wav(self):
|
||||
|
||||
parser = MediaFileParser([], "test_files/")
|
||||
parser = MediaFileParser([], dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse("./test_files/cat1.wav")
|
||||
info = parser.parse(dir_name + "/test_files/cat1.wav")
|
||||
|
||||
self.assertEqual(info["format_long_name"], "WAV / WAVE (Waveform Audio)")
|
||||
self.assertEqual(info["duration"], 20.173875)
|
||||
|
||||
def test_video_mov(self):
|
||||
parser = MediaFileParser([], "./test_files")
|
||||
parser = MediaFileParser([], dir_name + "/test_files")
|
||||
|
||||
info = parser.parse("./test_files/vid1.mp4")
|
||||
info = parser.parse(dir_name + "/test_files/vid1.mp4")
|
||||
|
||||
self.assertEqual(info["format_long_name"], "QuickTime / MOV")
|
||||
self.assertEqual(info["duration"], 5.334)
|
||||
@ -24,7 +27,7 @@ class MediaFileParserTest(TestCase):
|
||||
def test_video_webm(self):
|
||||
parser = MediaFileParser([], "test_files/")
|
||||
|
||||
info = parser.parse("test_files/vid2.webm")
|
||||
info = parser.parse(dir_name + "/test_files/vid2.webm")
|
||||
|
||||
self.assertEqual(info["format_long_name"], "Matroska / WebM")
|
||||
self.assertEqual(info["duration"], 10.619)
|
||||
@ -32,7 +35,7 @@ class MediaFileParserTest(TestCase):
|
||||
def test_video_ogg(self):
|
||||
parser = MediaFileParser([], "test_files/")
|
||||
|
||||
info = parser.parse("test_files/vid3.ogv")
|
||||
info = parser.parse(dir_name + "/test_files/vid3.ogv")
|
||||
|
||||
self.assertEqual(info["format_long_name"], "Ogg")
|
||||
self.assertEqual(info["duration"], 10.618867)
|
26
test/test_MimeGuesser.py
Normal file
@ -0,0 +1,26 @@
|
||||
from parsing import ContentMimeGuesser, ExtensionMimeGuesser
|
||||
from unittest import TestCase
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MimeGuesserTest(TestCase):
|
||||
|
||||
def test_content_guesser(self):
|
||||
|
||||
guesser = ContentMimeGuesser()
|
||||
|
||||
self.assertEqual("text/x-shellscript", guesser.guess_mime(dir_name + "/test_folder/test_utf8.sh"))
|
||||
self.assertEqual("text/plain", guesser.guess_mime(dir_name + "/test_folder/more_books.json"))
|
||||
self.assertEqual("application/java-archive", guesser.guess_mime(dir_name + "/test_folder/post.jar"))
|
||||
self.assertEqual("image/jpeg", guesser.guess_mime(dir_name + "/test_folder/sample_1.jpg"))
|
||||
|
||||
def test_extension_guesser(self):
|
||||
|
||||
guesser = ExtensionMimeGuesser()
|
||||
|
||||
self.assertEqual("text/x-sh", guesser.guess_mime(dir_name + "/test_folder/test_utf8.sh"))
|
||||
self.assertEqual("application/json", guesser.guess_mime(dir_name + "/test_folder/more_books.json"))
|
||||
self.assertEqual("application/java-archive", guesser.guess_mime(dir_name + "/test_folder/post.jar"))
|
||||
self.assertEqual("image/jpeg", guesser.guess_mime(dir_name + "/test_folder/sample_1.jpg"))
|
@ -1,5 +1,8 @@
|
||||
from unittest import TestCase
|
||||
from parsing import PdfFileParser
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class PdfParserTest(TestCase):
|
||||
@ -8,7 +11,7 @@ class PdfParserTest(TestCase):
|
||||
|
||||
parser = PdfFileParser([], 12488, "test_files/")
|
||||
|
||||
info = parser.parse("test_files/pdf1.pdf")
|
||||
info = parser.parse(dir_name + "/test_files/pdf1.pdf")
|
||||
|
||||
self.assertEqual(len(info["content"]), 12488)
|
||||
self.assertTrue(info["content"].startswith("Rabies\n03/11/2011\nRabies"))
|
@ -1,14 +1,17 @@
|
||||
from unittest import TestCase
|
||||
from parsing import PictureFileParser
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class PictureFileParserTest(TestCase):
|
||||
|
||||
def test_parse_jpg(self):
|
||||
|
||||
parser = PictureFileParser([], "test_files/")
|
||||
parser = PictureFileParser([], dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse("test_folder/sample_1.jpg")
|
||||
info = parser.parse( dir_name + "/test_folder/sample_1.jpg")
|
||||
|
||||
self.assertEqual(info["mode"], "RGB")
|
||||
self.assertEqual(info["width"], 420)
|
||||
@ -17,9 +20,9 @@ class PictureFileParserTest(TestCase):
|
||||
|
||||
def test_parse_png(self):
|
||||
|
||||
parser = PictureFileParser([], "test_files/")
|
||||
parser = PictureFileParser([], dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse("test_folder/sample_5.png")
|
||||
info = parser.parse( dir_name + "/test_folder/sample_5.png")
|
||||
|
||||
self.assertEqual(info["mode"], "RGBA")
|
||||
self.assertEqual(info["width"], 288)
|
||||
@ -28,9 +31,9 @@ class PictureFileParserTest(TestCase):
|
||||
|
||||
def test_parse_gif(self):
|
||||
|
||||
parser = PictureFileParser([], "test_files/")
|
||||
parser = PictureFileParser([], dir_name + "/test_files/")
|
||||
|
||||
info = parser.parse("test_folder/sample_6.gif")
|
||||
info = parser.parse( dir_name + "/test_folder/sample_6.gif")
|
||||
|
||||
self.assertEqual(info["mode"], "P")
|
||||
self.assertEqual(info["width"], 420)
|
||||
@ -41,7 +44,7 @@ class PictureFileParserTest(TestCase):
|
||||
|
||||
parser = PictureFileParser([], "test_files/")
|
||||
|
||||
info = parser.parse("test_folder/sample_7.bmp")
|
||||
info = parser.parse( dir_name + "/test_folder/sample_7.bmp")
|
||||
|
||||
self.assertEqual(info["mode"], "RGB")
|
||||
self.assertEqual(info["width"], 150)
|
@ -1,6 +1,10 @@
|
||||
from unittest import TestCase
|
||||
from parsing import SpreadSheetParser
|
||||
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class PdfParserTest(TestCase):
|
||||
|
||||
@ -8,7 +12,7 @@ class PdfParserTest(TestCase):
|
||||
|
||||
parser = SpreadSheetParser([], 1500, "test_files/")
|
||||
|
||||
info = parser.parse("test_files/xls1.xls")
|
||||
info = parser.parse(dir_name + "/test_files/xls1.xls")
|
||||
|
||||
self.assertEqual(len(info["content"]), 1500)
|
||||
|
||||
@ -16,6 +20,6 @@ class PdfParserTest(TestCase):
|
||||
|
||||
parser = SpreadSheetParser([], 1500, "test_files/")
|
||||
|
||||
info = parser.parse("test_files/xlsx1.xlsx")
|
||||
info = parser.parse(dir_name + "/test_files/xlsx1.xlsx")
|
||||
|
||||
self.assertEqual(len(info["content"]), 1500)
|
@ -1,5 +1,8 @@
|
||||
from unittest import TestCase
|
||||
from parsing import TextFileParser
|
||||
import os
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class TextFileParserTest(TestCase):
|
||||
@ -8,7 +11,7 @@ class TextFileParserTest(TestCase):
|
||||
|
||||
parser = TextFileParser([], 1234, "test_files/")
|
||||
|
||||
info = parser.parse("test_files/text.csv")
|
||||
info = parser.parse(dir_name + "/test_files/text.csv")
|
||||
|
||||
self.assertTrue(info["content"].startswith("rosbagTimestamp,header,seq,stamp,secs,nsecs,"))
|
||||
self.assertEqual(len(info["content"]), 1309) # Size is larger because of html escaping
|
0
test/test_files/Sound sample licence
Normal file
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 3.9 MiB After Width: | Height: | Size: 3.9 MiB |
Before Width: | Height: | Size: 348 KiB After Width: | Height: | Size: 348 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
@ -1,15 +0,0 @@
|
||||
import os
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if not os.path.isdir("big_dir"):
|
||||
os.mkdir("big_dir")
|
||||
|
||||
for i in range(100):
|
||||
|
||||
if not os.path.isdir("big_dir/" + str(i)):
|
||||
os.mkdir("big_dir/" + str(i))
|
||||
|
||||
for j in range(10000):
|
||||
open("big_dir/" + str(i) + "/file-" + str(j), 'a').close()
|