def testReturnsTiddlerElements(self): """_get_tiddler_elements returns element nodes""" doc = _getTiddlyWiki("modern") nodes = main._get_tiddler_elements(doc) actual = nodes[0].name expected = "div" self.assertEqual(actual, expected)
def testSupportsLegacyStore(self): """_get_text supports legacy (pre-v2.2) store format""" doc = _getTiddlyWiki("legacy") tiddlers = main._get_tiddler_elements(doc) actual = main._get_text(tiddlers[1]) expected = u"consectetur adipisicing elit" self.assertEqual(expected, actual)
def testDecodesLegacyTiddlers(self): """_get_text decodes legacy-store tiddlers' contents""" doc = _getTiddlyWiki("legacy") tiddlers = main._get_tiddler_elements(doc) actual = main._get_text(tiddlers[0]) expected = u"l\xf6rem ips\xfcm\n\nd\xc5lor s\xe4t\n\xe6met" self.assertEqual(expected, actual)
def testSupportsModernStore(self): """_get_title supports modern (v2.2+) store format""" doc = _getTiddlyWiki("modern") tiddlers = main._get_tiddler_elements(doc) actual = main._get_title(tiddlers[0]) expected = "Foo" self.assertEqual(expected, actual)
def testSupportsModernStore(self): """_get_text supports modern (v2.2+) store format""" doc = _getTiddlyWiki("modern") tiddlers = main._get_tiddler_elements(doc) actual = main._get_text(tiddlers[0]) expected = u"l\xf6rem ips\xfcm\n\nd\xc5lor s\xe4t\n\xe6met" self.assertEqual(expected, actual)
def testSupportsLegacyStore(self): """_get_title supports legacy (pre-v2.2) store format""" doc = _getTiddlyWiki("legacy") tiddlers = main._get_tiddler_elements(doc) actual = main._get_title(tiddlers[0]) expected = "Foo" self.assertEqual(expected, actual)
def testReturnsTiddlerItems(self): """_get_tiddler_elements returns one item per tiddler element""" doc = _getTiddlyWiki("modern") items = main._get_tiddler_elements(doc) actual = len(items) expected = 2 self.assertEqual(actual, expected)
def testReturnsTiddlerContents(self): """_get_title returns tiddler name""" doc = _getTiddlyWiki("modern") tiddlers = main._get_tiddler_elements(doc) actual = main._get_title(tiddlers[1]) expected = "Bar" self.assertEqual(expected, actual)
def testReturnsTiddlerContents(self): """_get_text returns tiddler elements' contents""" doc = _getTiddlyWiki("modern") tiddlers = main._get_tiddler_elements(doc) actual = main._get_text(tiddlers[1]) expected = u"consectetur adipisicing elit" self.assertEqual(expected, actual)
def testProvidesTiddlerCreated(self): """_generate_tiddler returns Tiddler's created attribute""" doc = _getTiddlyWiki("legacy") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[1]) actual = tiddler.created expected = datetime(2009, 03, 26, 10, 42) self.assertEqual(actual, expected)
def testProvidesTiddlerFields(self): """_generate_tiddler returns Tiddler's extended fields""" doc = _getTiddlyWiki("legacy") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[1]) actual = tiddler.fields expected = { "changecount": "1" } self.assertEqual(actual, expected)
def testProvidesTiddlerTags(self): """_generate_tiddler returns Tiddler's tags""" doc = _getTiddlyWiki("modern") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[0]) actual = tiddler.tags expected = ["test", "tmp", u"x\xf6x"] self.assertEqual(actual, expected)
def testProvidesTiddlerModifier(self): """_generate_tiddler returns Tiddler's modifier""" doc = _getTiddlyWiki("modern") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[1]) actual = tiddler.modifier expected = "FND" self.assertEqual(actual, expected)
def testProvidesTiddlerModified(self): """_generate_tiddler returns Tiddler's modified attribute""" doc = _getTiddlyWiki("modern") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[0]) actual = tiddler.modified expected = datetime(2009, 03, 26, 10, 43) self.assertEqual(actual, expected)
def testProvidesTiddlerTitle(self): """_generate_tiddler returns Tiddler's title""" doc = _getTiddlyWiki("modern") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[1]) actual = tiddler.title expected = "Bar" self.assertEqual(actual, expected)
def testReturnsTiddler(self): """_generate_tiddler returns Tiddler instance""" doc = _getTiddlyWiki("modern") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[0]) actual = tiddler.title expected = "Foo" self.assertEqual(actual, expected)
def testProvidesTiddlerText(self): """_generate_tiddler returns Tiddler's text""" doc = _getTiddlyWiki("legacy") tiddlerElements = main._get_tiddler_elements(doc) tiddler = main._generate_tiddler(tiddlerElements[0]) actual = tiddler.text expected = u"l\xf6rem ips\xfcm\n\nd\xc5lor s\xe4t\n\xe6met" self.assertEqual(actual, expected)
def testReturnsList(self): """_get_tiddler_elements returns empty list if no tiddlers in store""" doc = _getTiddlyWiki() actual = main._get_tiddler_elements(doc) expected = [] self.assertEqual(actual, expected)