2013-06-14 00:35:51 +03:00
|
|
|
#!/usr/bin/env python2.7
|
2013-06-03 22:57:55 +03:00
|
|
|
|
|
|
|
import unittest
|
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
import sections
|
|
|
|
|
|
|
|
class TestSection(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_create(self):
|
2013-06-04 23:40:09 +03:00
|
|
|
sec = sections.Section("nnn", "text")
|
|
|
|
self.assertEqual(sec.name, "nnn")
|
|
|
|
self.assertEqual(sec.text, "text")
|
2013-06-03 22:57:55 +03:00
|
|
|
|
2013-06-04 23:44:50 +03:00
|
|
|
def test_add_tags(self):
|
|
|
|
sec = sections.Section("nnn", "text")
|
|
|
|
sec.add_tags(['a', 'b'])
|
|
|
|
self.assertTrue(sec.hastag('a'))
|
|
|
|
self.assertTrue(sec.hastag('b'))
|
|
|
|
sec.add_tags(['c', 'd'])
|
|
|
|
self.assertTrue(sec.hastag('a'))
|
|
|
|
self.assertTrue(sec.hastag('b'))
|
|
|
|
self.assertTrue(sec.hastag('c'))
|
|
|
|
self.assertTrue(sec.hastag('d'))
|
|
|
|
|
2013-06-03 22:57:55 +03:00
|
|
|
class TestBook(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_create(self):
|
2013-06-04 23:40:09 +03:00
|
|
|
b = sections.Book()
|
|
|
|
self.assertEqual(b.sections, [])
|
|
|
|
self.assertEqual(b.nr_sections, {})
|
2013-06-14 00:35:51 +03:00
|
|
|
self.assertEqual(b.config['max'], 0)
|
2013-06-03 22:57:55 +03:00
|
|
|
|
2013-06-17 00:43:45 +03:00
|
|
|
def test_includetag(self):
|
2014-03-01 00:23:18 +02:00
|
|
|
b = sections.Book(includetags=['test'])
|
2013-06-17 00:43:45 +03:00
|
|
|
sec = sections.Section("nnn", "text")
|
|
|
|
sec.add_tags(['some', 'test', 'other'])
|
|
|
|
b.add(sec)
|
|
|
|
self.assertEqual(b.sections, [sec])
|
|
|
|
|
|
|
|
def test_excludetag(self):
|
2014-03-01 00:23:18 +02:00
|
|
|
b = sections.Book(includetags=['test'])
|
2013-06-17 00:43:45 +03:00
|
|
|
sec = sections.Section("nnn", "text")
|
|
|
|
sec.add_tags(['some', 'other'])
|
|
|
|
b.add(sec)
|
|
|
|
self.assertEqual(b.sections, [])
|
|
|
|
|
2013-06-03 22:57:55 +03:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|