test for file path parsing

This commit is contained in:
Stephan Gabler 2012-07-18 10:38:25 +02:00
parent 9796f5b0b0
commit d323e5f131
4 changed files with 69 additions and 1 deletions

0
tests/empty.txt Normal file
View file

View file

@ -2,6 +2,8 @@
# encoding: utf-8
import unittest
import os
from jrnl.Journal import Journal
class TestClasses(unittest.TestCase):
"""Test the behavior of the classes.
@ -11,12 +13,52 @@ class TestClasses(unittest.TestCase):
"""
def setUp(self):
self.data_path = os.path.dirname(os.path.abspath(__file__))
self.config = {
"timeformat": "%Y-%m-%d %H:%M",
"encrypt": False,
"tagsymbols": "@",
"journal": ""
}
def tearDown(self):
# TODO: delete copied file, etc
pass
def test_colon_in_textbody(self):
"""colons should not cause problems in the text body"""
pass
# def test_file_detection(self):
# self.config['journal'] = os.path.join(self.data_path, 'empty.txt')
# journal = Journal(config=self.config)
# with open(os.path.join(self.data_path, 'url_test.txt')) as f:
# journal.new_entry(f.read())
# # TODO: check that copied file exists
def test_rendering_md(self):
pass
def test_rendering_htm(self):
pass
def test_open_in_browser(self):
pass
def test_pathsearch_regex(self):
true_positive = ['/Volumes/dedan/bla.png',
'/Users/dedan/projects/jrnl/tests/golden.jpg',
'/Volumes/dedan/test.png']
false_positive = ['/Volumes/dedan/bla.blub',
'http://en.wikipedia.org/wiki/Generative_model']
self.config['journal'] = os.path.join(self.data_path, 'empty.txt')
journal = Journal(config=self.config)
with open(os.path.join(self.data_path, 'url_test.txt')) as f:
results = [res[0] for res in journal.path_search.findall(f.read())]
for tp in true_positive:
self.assertIn(tp, results)
for fp in false_positive:
self.assertNotIn(fp, results)
class TestCLI(unittest.TestCase):
"""test the command-line interaction part of the program"""

6
tests/url_test.txt Normal file
View file

@ -0,0 +1,6 @@
ein normalser satz.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, (/Volumes/dedan/bla.png
) sed do eiusmod tempor incididunt ut (http://en.wikipedia.org/wiki/Generative_model) labore et dolore magna aliqua. Ut enim ad minim veniam, (/Users/dedan/projects/jrnl/tests/golden.jpg)
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor http://www.dict.cc/?s=descendant in reprehenderit in voluptate velit esse /Volumes/dedan/test.png cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non (/Volumes/dedan/bla.blub) proident, sunt in culpa qui officia deserunt mollit anim id est laborum.