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)
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])
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])
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])
def canonicalise(self, wsNames): self.localReference = self.localReference.upper() FLReferenceParseNode.canonicalise(self, wsNames)
def __init__(self, children): FLReferenceParseNode.__init__(self, ParseNode.FL_COLUMN_REFERENCE, children)
def __init__(self, children): FLReferenceParseNode.__init__(self, ParseNode.FL_CELL_REFERENCE, children)
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)