Exemplo n.º 1
0
    def testCanonicalise(self):
        def assertCanon(reference, worksheetNames, expected):
            ref = FLReferenceParseNode(None, [reference, '!', sentinel.onlyChild])
            ref.canonicalise(worksheetNames)
            self.assertEquals(ref.children[0], expected)

        assertCanon('foo', ['foO'], 'foO')
        assertCanon('foo', [], 'foo')
        assertCanon("'''s'", ["'S"], "'''S'")
        assertCanon("foo  ", [], 'foo  ')

        ref = FLReferenceParseNode(None, ['A1'])
        ref.canonicalise([])
        self.assertEquals(ref.worksheetReference, None)
Exemplo n.º 2
0
    def testCanonicalise(self):
        def assertCanon(reference, worksheetNames, expected):
            ref = FLReferenceParseNode(None,
                                       [reference, '!', sentinel.onlyChild])
            ref.canonicalise(worksheetNames)
            self.assertEquals(ref.children[0], expected)

        assertCanon('foo', ['foO'], 'foO')
        assertCanon('foo', [], 'foo')
        assertCanon("'''s'", ["'S"], "'''S'")
        assertCanon("foo  ", [], 'foo  ')

        ref = FLReferenceParseNode(None, ['A1'])
        ref.canonicalise([])
        self.assertEquals(ref.worksheetReference, None)
Exemplo n.º 3
0
    def testInit(self):
        self.assertRaises(AssertionError, FLReferenceParseNode, sentinel.type,
                          [sentinel.firstChild, sentinel.secondChild])
        self.assertRaises(AssertionError, FLReferenceParseNode, sentinel.type,
                          [sentinel.child] * 4)

        ref = FLReferenceParseNode(sentinel.type, [sentinel.firstChild])
        self.assertEquals(ref.type, sentinel.type)
        self.assertEquals(ref.children, [sentinel.firstChild])

        ref = FLReferenceParseNode(
            sentinel.type,
            [sentinel.firstChild, sentinel.secondChild, sentinel.thirdChild])
        self.assertEquals(ref.type, sentinel.type)
        self.assertEquals(
            ref.children,
            [sentinel.firstChild, sentinel.secondChild, sentinel.thirdChild])
Exemplo n.º 4
0
    def testWorksheetReferenceProperty(self):
        ref = FLReferenceParseNode(None, [sentinel.onlyChild])
        self.assertEquals(ref.worksheetReference, None)

        ref = FLReferenceParseNode(
            None, ["'Thin Lizzy'    ", sentinel.second, sentinel.third])
        self.assertEquals(ref.children[0], "'Thin Lizzy'    ")
        self.assertEquals(ref.worksheetReference, 'Thin Lizzy')

        # loses the whitespace information
        ref.worksheetReference = None
        self.assertEquals(ref.children, [sentinel.third])

        # therefore no whitespace information here
        ref.worksheetReference = "Ben Folds' Five    "
        self.assertEquals(ref.children,
                          ["'Ben Folds'' Five    '", '!', sentinel.third])
        self.assertEquals(ref.worksheetReference, "Ben Folds' Five    ")

        ref.children[0] = "'with trailing whitespace'   "
        ref.worksheetReference = "Shihad"
        self.assertEquals(ref.children, ["Shihad   ", '!', sentinel.third])
Exemplo n.º 5
0
    def testWorksheetReferenceProperty(self):
        ref = FLReferenceParseNode(None, [sentinel.onlyChild])
        self.assertEquals(ref.worksheetReference, None)

        ref = FLReferenceParseNode(None, ["'Thin Lizzy'    ", sentinel.second, sentinel.third])
        self.assertEquals(ref.children[0], "'Thin Lizzy'    ")
        self.assertEquals(ref.worksheetReference, 'Thin Lizzy')

        # loses the whitespace information
        ref.worksheetReference = None
        self.assertEquals(ref.children, [sentinel.third])

        # therefore no whitespace information here
        ref.worksheetReference = "Ben Folds' Five    "
        self.assertEquals(ref.children, ["'Ben Folds'' Five    '", '!', sentinel.third])
        self.assertEquals(ref.worksheetReference, "Ben Folds' Five    ")

        ref.children[0] = "'with trailing whitespace'   "
        ref.worksheetReference = "Shihad"
        self.assertEquals(ref.children, ["Shihad   ", '!', sentinel.third])
Exemplo n.º 6
0
 def canonicalise(self, wsNames):
     self.localReference = self.localReference.upper()
     FLReferenceParseNode.canonicalise(self, wsNames)
Exemplo n.º 7
0
 def __init__(self, children):
     FLReferenceParseNode.__init__(self, ParseNode.FL_COLUMN_REFERENCE, children)
Exemplo n.º 8
0
 def assertCanon(reference, worksheetNames, expected):
     ref = FLReferenceParseNode(None,
                                [reference, '!', sentinel.onlyChild])
     ref.canonicalise(worksheetNames)
     self.assertEquals(ref.children[0], expected)
Exemplo n.º 9
0
 def assertCanon(reference, worksheetNames, expected):
     ref = FLReferenceParseNode(None, [reference, '!', sentinel.onlyChild])
     ref.canonicalise(worksheetNames)
     self.assertEquals(ref.children[0], expected)
 def __init__(self, children):
     FLReferenceParseNode.__init__(self, ParseNode.FL_NAMED_ROW_REFERENCE,
                                   children)
 def __init__(self, children):
     FLReferenceParseNode.__init__(self, ParseNode.FL_NAMED_ROW_REFERENCE, children)