1 | # Copyright (c) Ralph Meijer. |
---|
2 | # See LICENSE for details. |
---|
3 | |
---|
4 | """ |
---|
5 | Tests for L{wokkel.format} |
---|
6 | """ |
---|
7 | |
---|
8 | from __future__ import division, absolute_import |
---|
9 | |
---|
10 | from twisted.trial import unittest |
---|
11 | from twisted.words.xish import domish |
---|
12 | |
---|
13 | from wokkel import formats |
---|
14 | |
---|
15 | class 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 | |
---|
33 | class 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) |
---|