Пример #1
0
    def testPlainColumnName(self):
        self.assertEquals(FLColumnReferenceParseNode(["A_"]).plainColumnName, "A", "Incorrect plainColumnName for A_")
        self.assertEquals(FLColumnReferenceParseNode(["$A_"]).plainColumnName, "A", "Incorrect plaiaColumName for $A_")

        self.assertEquals(FLColumnReferenceParseNode(["SheetSomething", "! ", "A_"]).plainColumnName, "A",
                          "Incorrect plainColumnName for A_ with worksheet")
        self.assertEquals(FLColumnReferenceParseNode(["SheetSomething", "! ", "$A_"]).plainColumnName, "A",
                          "Incorrect plainColumnName for $A_ with worksheet")
Пример #2
0
    def testIsAbsolute(self):
        self.assertFalse(FLColumnReferenceParseNode(["A_"]).isAbsolute, "Incorrect isAbsolute for A_")
        self.assertTrue(FLColumnReferenceParseNode(["$A_"]).isAbsolute, "Incorrect isAbsolute for $A_")
        self.assertTrue(FLColumnReferenceParseNode([" $A_"]).isAbsolute, "Incorrect isAbsolute for  $A_")

        self.assertFalse(FLColumnReferenceParseNode(["SheetSomething", "! ", "A_"]).isAbsolute,
                         "Incorrect isAbsolute for A_ with worksheet")
        self.assertTrue(FLColumnReferenceParseNode(["SheetSomething", "! ", "$A_"]).isAbsolute,
                         "Incorrect isAbsolute for $A_ with worksheet")
Пример #3
0
 def testOffset(self):
     node = FLColumnReferenceParseNode(['B_ '])
     node.offset(0, 1000)
     self.assertEquals(node.localReference, 'B_ ')
     node.offset(1, -1000)
     self.assertEquals(node.localReference, 'C_ ')
     node.offset(-2, 0)
     self.assertEquals(node.localReference, 'A_ ')
     node.offset(-1, 1337)
     self.assertEquals(node.localReference, '#Invalid! ')
Пример #4
0
    def testSubclasses(self):
        self.assertNotEqual(type(FLCellReferenceParseNode(["A1"])), ParseNode,
                            "Subclass of ParseNode had incorrect type")

        self.assertNotEqual(type(FLColumnReferenceParseNode(['A_'])),
                            ParseNode,
                            "Subclass of ParseNode had incorrect type")

        self.assertNotEqual(type(FLRowReferenceParseNode([])), ParseNode,
                            "Subclass of ParseNode had incorrect type")
Пример #5
0
    def testOffsetAbsoluteRefs(self):
        node = FLColumnReferenceParseNode(['$C_ '])
        node.offset(54, 0xDEADBEEF)
        self.assertEquals(node.localReference, '$C_ ')

        node.offset(4, 0xDEADBEEF, moveAbsolute=True)
        self.assertEquals(node.localReference, '$G_ ')
Пример #6
0
    def testSettingColumnProperty(self):
        column = FLColumnReferenceParseNode(["A_ "])
        column.localReference = "12345"
        self.assertEquals(column.localReference, "12345")

        column = FLColumnReferenceParseNode(["$A_ "])
        column.localReference = "#Deleted!"
        self.assertEquals(column.localReference, "#Deleted!")
Пример #7
0
    def testSettingPlainColumnName(self):
        column = FLColumnReferenceParseNode(["A_ "])
        column.plainColumnName = "C"
        self.assertEquals(column.localReference, "C_ ")

        column = FLColumnReferenceParseNode(["$A_ "])
        column.plainColumnName = "C"
        self.assertEquals(column.localReference, "$C_ ")
Пример #8
0
 def testCanonicalise(self):
     node = FLColumnReferenceParseNode(["sheet1  ", "!", "$d_"])
     node.canonicalise(['Sheet1'])
     self.assertEquals(node.localReference, '$D_')
     self.assertEquals(node.worksheetReference, 'Sheet1')
Пример #9
0
 def testColIndexProperty(self):
     self.assertEquals(FLColumnReferenceParseNode(["D_"]).colIndex, 4)
     self.assertEquals(FLColumnReferenceParseNode(["$B_"]).colIndex, 2)
Пример #10
0
 def testColumnReferenceProperty(self):
     self.assertEquals(FLColumnReferenceParseNode(["A_"]).localReference, "A_")
     self.assertEquals(FLColumnReferenceParseNode(["ws1", "!", "A_"]).localReference, "A_")
Пример #11
0
 def testStr(self):
     node = FLColumnReferenceParseNode(["a_"])
     self.assertEquals(str(node), "<FLColumnReferenceParseNode type=\"FL_COLUMN_REFERENCE\" children=['a_']>", "Wrong string representation")
Пример #12
0
 def testConstructor(self):
     flColumnReference = FLColumnReferenceParseNode(["A_"])
     self.assertTrue(isinstance(flColumnReference, FLReferenceParseNode), 'should be a parse node')
     self.assertEquals(flColumnReference.type, ParseNode.FL_COLUMN_REFERENCE, "Node was of the wrong type")
     self.assertEquals(flColumnReference.children, ["A_"], "Node had the wrong children")
Пример #13
0
    def testCoords(self):
        node = FLColumnReferenceParseNode(['$A_ '])
        self.assertEquals(node.coords, (1, 0))

        node = FLColumnReferenceParseNode(['B_ '])
        self.assertEquals(node.coords, (2, 0))
Пример #14
0
    def testSimpleConvenienceConstructors(self):
        randomList = ["foo", "bar", 27]

        self.assertEquals(ParseNode(ParseNode.AND_TEST, randomList),
                          AndTest(randomList))
        self.assertEquals(ParseNode(ParseNode.ARG_LIST, randomList),
                          ArgList(randomList))
        self.assertEquals(ParseNode(ParseNode.ARGUMENT, randomList),
                          Argument(randomList))
        self.assertEquals(ParseNode(ParseNode.ARITH_EXPR, randomList),
                          ArithExpr(randomList))
        self.assertEquals(ParseNode(ParseNode.ATOM, randomList),
                          Atom(randomList))
        self.assertEquals(ParseNode(ParseNode.COMPARISON, randomList),
                          Comparison(randomList))
        self.assertEquals(ParseNode(ParseNode.COMP_OPERATOR, randomList),
                          CompOperator(randomList))
        self.assertEquals(ParseNode(ParseNode.CONCAT_EXPR, randomList),
                          ConcatExpr(randomList))
        self.assertEquals(ParseNode(ParseNode.DICT_MAKER, randomList),
                          DictMaker(randomList))
        self.assertEquals(ParseNode(ParseNode.EXPR, randomList),
                          Expr(randomList))
        self.assertEquals(ParseNode(ParseNode.EXPR_LIST, randomList),
                          ExprList(randomList))
        self.assertEquals(ParseNode(ParseNode.FACTOR, randomList),
                          Factor(randomList))
        self.assertEquals(FLCellRangeParseNode(randomList),
                          FLCellRange(randomList))
        self.assertEquals(FLCellReferenceParseNode(randomList),
                          FLCellReference(randomList))
        self.assertEquals(FLColumnReferenceParseNode(randomList),
                          FLColumnReference(randomList))
        self.assertEquals(FLRowReferenceParseNode(randomList),
                          FLRowReference(randomList))
        self.assertEquals(ParseNode(ParseNode.FL_DDE_CALL, randomList),
                          FLDDECall(randomList))
        self.assertEquals(
            ParseNode(ParseNode.FL_DELETED_REFERENCE, randomList),
            FLDeletedReference(randomList))
        self.assertEquals(
            ParseNode(ParseNode.FL_INVALID_REFERENCE, randomList),
            FLInvalidReference(randomList))
        self.assertEquals(
            ParseNode(ParseNode.FL_NAKED_WORKSHEET_REFERENCE, randomList),
            FLNakedWorksheetReference(randomList))
        self.assertEquals(ParseNode(ParseNode.FL_REFERENCE, randomList),
                          FLReference(randomList))
        self.assertEquals(ParseNode(ParseNode.FL_ROOT, randomList),
                          FLRoot(randomList))
        self.assertEquals(ParseNode(ParseNode.FP_DEF, randomList),
                          FPDef(randomList))
        self.assertEquals(ParseNode(ParseNode.FP_LIST, randomList),
                          FPList(randomList))
        self.assertEquals(ParseNode(ParseNode.GEN_FOR, randomList),
                          GenFor(randomList))
        self.assertEquals(ParseNode(ParseNode.GEN_IF, randomList),
                          GenIf(randomList))
        self.assertEquals(ParseNode(ParseNode.GEN_ITER, randomList),
                          GenIter(randomList))
        self.assertEquals(ParseNode(ParseNode.LAMBDEF, randomList),
                          LambDef(randomList))
        self.assertEquals(ParseNode(ParseNode.LIST_FOR, randomList),
                          ListFor(randomList))
        self.assertEquals(ParseNode(ParseNode.LIST_IF, randomList),
                          ListIf(randomList))
        self.assertEquals(ParseNode(ParseNode.LIST_ITER, randomList),
                          ListIter(randomList))
        self.assertEquals(ParseNode(ParseNode.LIST_MAKER, randomList),
                          ListMaker(randomList))
        self.assertEquals(ParseNode(ParseNode.NAME, randomList),
                          Name(randomList))
        self.assertEquals(ParseNode(ParseNode.NOT_TEST, randomList),
                          NotTest(randomList))
        self.assertEquals(ParseNode(ParseNode.NUMBER, randomList),
                          Number(randomList))
        self.assertEquals(ParseNode(ParseNode.POWER, randomList),
                          Power(randomList))
        self.assertEquals(ParseNode(ParseNode.SHIFT_EXPR, randomList),
                          ShiftExpr(randomList))
        self.assertEquals(ParseNode(ParseNode.SLICE_OP, randomList),
                          SliceOp(randomList))
        self.assertEquals(ParseNode(ParseNode.STRINGLITERAL, randomList),
                          StringLiteral(randomList))
        self.assertEquals(ParseNode(ParseNode.SUBSCRIPT, randomList),
                          Subscript(randomList))
        self.assertEquals(ParseNode(ParseNode.SUBSCRIPT_LIST, randomList),
                          SubscriptList(randomList))
        self.assertEquals(ParseNode(ParseNode.TERM, randomList),
                          Term(randomList))
        self.assertEquals(ParseNode(ParseNode.TEST, randomList),
                          Test(randomList))
        self.assertEquals(ParseNode(ParseNode.TEST_LIST, randomList),
                          TestList(randomList))
        self.assertEquals(ParseNode(ParseNode.TEST_LIST_GEXP, randomList),
                          TestListGexp(randomList))
        self.assertEquals(ParseNode(ParseNode.TRAILER, randomList),
                          Trailer(randomList))
        self.assertEquals(ParseNode(ParseNode.VAR_ARGS_LIST, randomList),
                          VarArgsList(randomList))