source: wokkel/test/test_formats.py @ 222:e1dafcc79586

Last change on this file since 222:e1dafcc79586 was 213:7b89b9208b88, checked in by Ralph Meijer <ralphm@…>, 6 years ago

Add tests for formats, fix py3 incompatibility.

File size: 1.4 KB
Line 
1# Copyright (c) Ralph Meijer.
2# See LICENSE for details.
3
4"""
5Tests for L{wokkel.format}
6"""
7
8from __future__ import division, absolute_import
9
10from twisted.trial import unittest
11from twisted.words.xish import domish
12
13from wokkel import formats
14
15class MoodTests(unittest.TestCase):
16    """
17    Tests for L{formats.Mood}.
18    """
19
20    def test_fromXml(self):
21        """
22        Moods are parsed from Elements.
23        """
24        element = domish.Element((formats.NS_MOOD, u'mood'))
25        element.addElement(u'happy')
26        element.addElement(u'text', content=u"Really happy!")
27        mood = formats.Mood.fromXml(element)
28        self.assertEquals(u'happy', mood.value)
29        self.assertEquals(u'Really happy!', mood.text)
30
31
32
33class TuneTests(unittest.TestCase):
34    """
35    Tests for L{formats.Tune}.
36    """
37
38    def test_fromXmlTrack(self):
39        """
40        The track filed in a user tune is parsed.
41        """
42        element = domish.Element((formats.NS_TUNE, u'tune'))
43        element.addElement(u'track', content=u"The Power")
44        tune = formats.Tune.fromXml(element)
45        self.assertEquals(u'The Power', tune.track)
46
47
48    def test_fromXmlLength(self):
49        """
50        The length filed in a user tune is parsed as an int.
51        """
52        element = domish.Element((formats.NS_TUNE, u'tune'))
53        element.addElement(u'length', content=u"322")
54        tune = formats.Tune.fromXml(element)
55        self.assertEquals(322, tune.length)
Note: See TracBrowser for help on using the repository browser.