Exemplo n.º 1
0
    def testDuplicateQuestionsNested(self):
        with open(lib.formFilePath("duplicateQuestionsNested.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

        self.checker.checkAST(parsed)

        self.assertEqual(len(self.duplicateQuestions.errors), 1)
Exemplo n.º 2
0
    def testIfElse(self):
        with open(lib.formFilePath("ifElse.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

            self.assertEquals(parsed.__class__.__name__, "Form")
            self.assertEquals(len(parsed.block), 1)

            file.close()
Exemplo n.º 3
0
    def testExpressions(self):
        with open(lib.formFilePath("expressions.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

            self.assertEquals(parsed.__class__.__name__, "Form")
            self.assertEquals(len(parsed.block), 13)

            file.close()
Exemplo n.º 4
0
    def testUndefinedQuestions(self):
        with open(lib.formFilePath("undefinedQuestions.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

        self.checker.checkAST(parsed)

        self.assertEqual(len(self.duplicateQuestions.errors), 0)
        self.assertEqual(len(self.undefinedQuestions.errors), 1)
    def testDuplicateQuestionsNested(self):
        with open(lib.formFilePath("duplicateQuestionsNested.txt"),
                  "r") as file:
            parsed = self.parser.parse(file.read())

        self.checker.checkAST(parsed)

        self.assertEqual(len(self.duplicateQuestions.errors), 1)
    def testUndefinedQuestions(self):
        with open(lib.formFilePath("undefinedQuestions.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

        self.checker.checkAST(parsed)

        self.assertEqual(len(self.duplicateQuestions.errors), 0)
        self.assertEqual(len(self.undefinedQuestions.errors), 1)
Exemplo n.º 7
0
    def testIfElse(self):
        with open(lib.formFilePath("ifElse.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

            self.assertEquals(parsed.__class__.__name__, "Form")
            self.assertEquals(len(parsed.block), 1)

            file.close()
Exemplo n.º 8
0
    def testExpressions(self):
        with open(lib.formFilePath("expressions.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

            self.assertEquals(parsed.__class__.__name__, "Form")
            self.assertEquals(len(parsed.block), 13)

            file.close()
Exemplo n.º 9
0
    def testIncompatibleNestedTypes(self):
        with open(lib.formFilePath("expressionTypesNested.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

        self.checker.checkAST(parsed)

        self.assertEqual(len(self.duplicateQuestions.errors), 0)
        self.assertEqual(len(self.undefinedQuestions.errors), 0)
        self.assertEqual(len(self.nonExpressions.errors), 4)
    def testIncompatibleNestedTypes(self):
        with open(lib.formFilePath("expressionTypesNested.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

        self.checker.checkAST(parsed)

        self.assertEqual(len(self.duplicateQuestions.errors), 0)
        self.assertEqual(len(self.undefinedQuestions.errors), 0)
        self.assertEqual(len(self.nonExpressions.errors), 4)
Exemplo n.º 11
0
    def testNestedIfBlocks(self):
        with open(lib.formFilePath("nestedIf.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

            self.assertEquals(parsed.__class__.__name__, "Form")
            self.assertEquals(len(parsed.block), 1)

            self.assertEquals(parsed.block[0].__class__.__name__, "Branch")
            self.assertEquals(len(parsed.block[0].ifChildren), 2)

            file.close()
Exemplo n.º 12
0
    def testNestedIfBlocks(self):
        with open(lib.formFilePath("nestedIf.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

            self.assertEquals(parsed.__class__.__name__, "Form")
            self.assertEquals(len(parsed.block), 1)

            self.assertEquals(parsed.block[0].__class__.__name__, "Branch")
            self.assertEquals(len(parsed.block[0].ifChildren), 2)

            file.close()
    def testFalseExpressions(self):
        with open(lib.formFilePath("falseExpressions.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

        gui = GUI()
        gui._buildForm(parsed)

        # Fire 'change' event
        gui.onChange()

        for node in gui.branches:
            if node.evaluate(gui.answers):
                print node
                print node.evaluate(gui.answers)
                print gui.answers
                print "-----"

            self.assertEqual(False, bool(node.evaluate(gui.answers)))
Exemplo n.º 14
0
    def testFalseExpressions(self):
        with open(lib.formFilePath("falseExpressions.txt"), "r") as file:
            parsed = self.parser.parse(file.read())

        gui = GUI()
        gui._buildForm(parsed)

        # Fire 'change' event
        gui.onChange()

        for node in gui.branches:
            if node.evaluate(gui.answers):
                print node
                print node.evaluate(gui.answers)
                print gui.answers
                print "-----"

            self.assertEqual(False, bool(node.evaluate(gui.answers)))
Exemplo n.º 15
0
    def testUndefinedType(self):
        with open(lib.formFilePath("undefinedType.txt"), "r") as file:
            self.assertRaises(ParseError, self.parser.parse, file.read())

            file.close()
Exemplo n.º 16
0
    def testUndefinedType(self):
        with open(lib.formFilePath("undefinedType.txt"), "r") as file:
            parsed = self.parser.parse(file.read())
            self.assertEquals(True, self.parser.hasErrors)

            file.close()