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 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()
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()
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 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 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)))
def testUndefinedType(self): with open(lib.formFilePath("undefinedType.txt"), "r") as file: self.assertRaises(ParseError, self.parser.parse, file.read()) file.close()
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()