# Path: wokkel/formats.py
# NS_MOOD = 'http://jabber.org/protocol/mood'
# NS_TUNE = 'http://jabber.org/protocol/tune'
# class Mood:
# class Tune:
#     def __init__(self, value, text=None):
#     def fromXml(self, element):
#     def fromXml(self, element):


from twisted.trial import unittest
from twisted.words.xish import domish
from wokkel import formats

class MoodTests(unittest.TestCase):
    """
    Tests for L{formats.Mood}.
    """

    def test_fromXml(self):
        """
        Moods are parsed from Elements.
        """
        element = domish.Element((formats.NS_MOOD, u'mood'))
        element.addElement(u'happy')
        element.addElement(u'text', content=u"Really happy!")
        mood = formats.Mood.fromXml(element)
        self.assertEquals(u'happy', mood.value)
        self.assertEquals(u'Really happy!', mood.text)



class TuneTests(unittest.TestCase):
    """
    Tests for L{formats.Tune}.
    """

    def test_fromXmlTrack(self):
        """
        The track filed in a user tune is parsed.
        """
        element = domish.Element((formats.NS_TUNE, u'tune'))
        element.addElement(u'track', content=u"The Power")

# Path: wokkel/formats.py
# NS_MOOD = 'http://jabber.org/protocol/mood'
# NS_TUNE = 'http://jabber.org/protocol/tune'
# class Mood:
# class Tune:
#     def __init__(self, value, text=None):
#     def fromXml(self, element):
#     def fromXml(self, element):


# Path: wokkel/test/test_formats.py
from twisted.trial import unittest
from twisted.words.xish import domish
from wokkel import formats


class MoodTests(unittest.TestCase):
    """
    Tests for L{formats.Mood}.
    """

    def test_fromXml(self):
        """
        Moods are parsed from Elements.
        """
        element = domish.Element((formats.NS_MOOD, u'mood'))
        element.addElement(u'happy')
        element.addElement(u'text', content=u"Really happy!")
        mood = formats.Mood.fromXml(element)
        self.assertEquals(u'happy', mood.value)
        self.assertEquals(u'Really happy!', mood.text)



class TuneTests(unittest.TestCase):
    """
    Tests for L{formats.Tune}.
    """

    def test_fromXmlTrack(self):
        """
        The track filed in a user tune is parsed.
        """
        element = domish.Element((formats.NS_TUNE, u'tune'))
        element.addElement(u'track', content=u"The Power")

        tune = formats.Tune.fromXml(element)