Example #1
0
class ParseNodeTestCase(unittest.TestCase):
    """
    Test Node creation by parser.
    """
    def setUp(self):
        """
        Create Danlann scanner and parser for album files.
        """
        self.scanner = DanlannScanner()
        self.parser = DanlannParser()


    def parse(self, line):
        """
        Parse string with Danlann parser and return node.

        @param line: string to parse

        @see danlann.parser.Node
        """
        return self.parser.parse(self.scanner.tokenize(line))


    def testAlbum(self):
        """simple album parsing"""
        node = self.parse('/a; title; desc')
        self.assertEquals(node.type, 'album')
        self.assertEquals(node.data, ['a', 'title', 'desc'])

        node = self.parse('/adir; title')
        self.assertEquals(node.type, 'album')
        self.assertEquals(node.data, ['adir', 'title', ''])


    def testSubalbum(self):
        """simple subalbum parsing"""
        node = self.parse('/adir04')
        self.assertEquals(node.type, 'subalbum')
        self.assertEquals(node.data, ['adir04'])


    def testPhoto(self):
        """simple photo parsing"""
        node = self.parse('abc')
        self.assertEquals(node.type, 'photo')
        self.assertEquals(node.data, ['abc', '', ''])

        node = self.parse('abc; title')
        self.assertEquals(node.type, 'photo')
        self.assertEquals(node.data, ['abc', 'title', ''])

        node = self.parse('abc; title; desc')
        self.assertEquals(node.type, 'photo')
        self.assertEquals(node.data, ['abc', 'title', 'desc'])
Example #2
0
 def setUp(self):
     """
     Create Danlann scanner and parser for album files.
     """
     self.scanner = DanlannScanner()
     self.parser = DanlannParser()