Esempio n. 1
0
    def testIsAbsolute(self):
        self.assertFalse(FLRowReferenceParseNode(["_1"]).isAbsolute, "Incorrect isAbsolute for _1")
        self.assertTrue(FLRowReferenceParseNode(["_$1"]).isAbsolute, "Incorrect isAbsolute for _$1")

        self.assertFalse(FLRowReferenceParseNode(["SheetSomething", "! ", "_1"]).isAbsolute,
                         "Incorrect isAbsolute for _1 with worksheet")
        self.assertTrue(FLRowReferenceParseNode(["SheetSomething", "! ", "_$1"]).isAbsolute,
                         "Incorrect isAbsolute for _$1 with worksheet")
Esempio n. 2
0
    def testPlainRowName(self):
        self.assertEquals(FLRowReferenceParseNode(["_1"]).plainRowName, "1", "Incorrect plainRowName for _1")
        self.assertEquals(FLRowReferenceParseNode(["_$1"]).plainRowName, "1", "Incorrect plaiaRowName for _$1")

        self.assertEquals(FLRowReferenceParseNode(["SheetSomething", "! ", "_1"]).plainRowName, "1",
                          "Incorrect plainRowName for _1 with worksheet")
        self.assertEquals(FLRowReferenceParseNode(["SheetSomething", "! ", "_$1"]).plainRowName, "1",
                          "Incorrect plainRowName for _$1 with worksheet")
Esempio n. 3
0
 def testOffset(self):
     node = FLRowReferenceParseNode(['_2 '])
     node.offset(1000, 0)
     self.assertEquals(node.localReference, '_2 ')
     node.offset(-1000, 1)
     self.assertEquals(node.localReference, '_3 ')
     node.offset(0, -2)
     self.assertEquals(node.localReference, '_1 ')
     node.offset(1337, -1)
     self.assertEquals(node.localReference, '#Invalid! ')
Esempio n. 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")
Esempio n. 5
0
    def testOffsetAbsoluteRefs(self):
        node = FLRowReferenceParseNode(['_$3 '])
        node.offset(0xDEADBEEF, 54)
        self.assertEquals(node.localReference, '_$3 ')

        node.offset(0xDEADBEEF, 4, moveAbsolute=True)
        self.assertEquals(node.localReference, '_$7 ')
Esempio n. 6
0
    def testSettingRowProperty(self):
        row = FLRowReferenceParseNode(["_1 "])
        row.localReference = "12345"
        self.assertEquals(row.localReference, "12345")

        row = FLRowReferenceParseNode(["_$1 "])
        row.localReference = "#Deleted!"
        self.assertEquals(row.localReference, "#Deleted!")
Esempio n. 7
0
    def testSettingPlainRowName(self):
        row = FLRowReferenceParseNode(["_1 "])
        row.plainRowName = "3"
        self.assertEquals(row.localReference, "_3 ")

        row = FLRowReferenceParseNode(["_$1 "])
        row.plainRowName = "3"
        self.assertEquals(row.localReference, "_$3 ")
Esempio n. 8
0
 def testRowIndexProperty(self):
     self.assertEquals(FLRowReferenceParseNode(["_4"]).rowIndex, 4)
     self.assertEquals(FLRowReferenceParseNode(["_$2"]).rowIndex, 2)
Esempio n. 9
0
 def testRowReferenceProperty(self):
     self.assertEquals(FLRowReferenceParseNode(["_1"]).localReference, "_1")
     self.assertEquals(FLRowReferenceParseNode(["ws1", "!", "_1"]).localReference, "_1")
Esempio n. 10
0
 def testStr(self):
     node = FLRowReferenceParseNode(["_1"])
     self.assertEquals(str(node), "<FLRowReferenceParseNode type=\"FL_ROW_REFERENCE\" children=['_1']>", "Wrong string representation")
Esempio n. 11
0
 def testConstructor(self):
     flRowReference = FLRowReferenceParseNode(["_1"])
     self.assertTrue(isinstance(flRowReference, FLReferenceParseNode), 'should be a parse node')
     self.assertEquals(flRowReference.type, ParseNode.FL_ROW_REFERENCE, "Node was of the wrong type")
     self.assertEquals(flRowReference.children, ["_1"], "Node had the wrong children")
Esempio n. 12
0
    def testCoords(self):
        node = FLRowReferenceParseNode(['_$1 '])
        self.assertEquals(node.coords, (0, 1))

        node = FLRowReferenceParseNode(['_2 '])
        self.assertEquals(node.coords, (0, 2))
Esempio n. 13
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))