示例#1
0
 def test_importValidXML(self):
     exercise = Exercise.fromXMLFile(dataPath("jemand1.xml"))
     self.assertEqual(exercise.schemaversion, 2)
     self.assertEqual(len(exercise.tags), 2)
     self.assertIn('aabc', exercise.tags)
     self.assertIsInstance(exercise.modified, datetime.datetime)
     self.assertIn('DE', exercise.tex_exercise)
     self.assertIn('DE', exercise.tex_solution)
     self.assertIn('EN', exercise.tex_solution)
     self.assertNotIn('EN', exercise.tex_exercise)
     self.assertIsInstance(exercise.number, int)
示例#2
0
 def test_importValidXML(self):
     exercise = Exercise.fromXMLFile(dataPath("jemand1.xml"))
     self.assertEqual(exercise.schemaversion, 2)
     self.assertEqual(len(exercise.tags), 2)
     self.assertIn('aabc', exercise.tags)
     self.assertIsInstance(exercise.modified, datetime.datetime)
     self.assertIn('DE', exercise.tex_exercise)
     self.assertIn('DE', exercise.tex_solution)
     self.assertIn('EN', exercise.tex_solution)
     self.assertNotIn('EN', exercise.tex_exercise)
     self.assertIsInstance(exercise.number, int)
示例#3
0
文件: test_repo.py 项目: mnechay/exdb
 def testRepositoryOperations(self):
     """Adds and removes exercises and checks the history."""
     numExercises = len(glob.glob(join(exdb.repo.repoPath(), "exercises", "*", "*.xml" )))
     self.assertEqual(len(exdb.sql.exercises()), numExercises)
     exes = exdb.sql.exercises()
     self.assertEqual(set(ex.creator for ex in exes), set(("jensmander", "foobar")))
     self.assertTrue(all(ex.number == 1 for ex in exes))
     
     exercise = Exercise.fromXMLFile(dataPath("jemand1.xml"))
     exercise.number = None
     exdb.addExercise(exercise, {})
     self.assertEqual(exercise.number, 1)
     self.assertEqual(len(exdb.sql.exercises()), numExercises+1)
     exdb.removeExercise("jensmander", 1)
     self.assertEqual(len(exdb.sql.exercises()), numExercises)
     exes = exdb.sql.exercises()
     self.assertNotIn("jensmander", (ex.creator for ex in exes))
     history = exdb.repo.history()
     self.assertEqual(history[0]["author"], "jensmander")
     self.assertEqual(history[0]["action"], "REMOVE")
     self.assertEqual(history[1]["action"], "ADD")
示例#4
0
 def test_MissingExerciseTex(self):
     import lxml
     self.assertRaises(lxml.etree.XMLSyntaxError,
                       lambda : Exercise.fromXMLFile(dataPath("invalid14.xml")))
示例#5
0
 def test_readPlainXML(self):
     self.assertTrue(Exercise.fromXMLFile(dataPath("noschemaandencoding.xml")))
示例#6
0
文件: repo.py 项目: mnechay/exdb
def loadFromXML(creator, number):
    from exdb.exercise import Exercise
    return Exercise.fromXMLFile(xmlPath(creator=creator, number=number))
示例#7
0
 def test_MissingExerciseTex(self):
     import lxml
     self.assertRaises(
         lxml.etree.XMLSyntaxError,
         lambda: Exercise.fromXMLFile(dataPath("invalid14.xml")))
示例#8
0
 def test_readPlainXML(self):
     self.assertTrue(
         Exercise.fromXMLFile(dataPath("noschemaandencoding.xml")))
示例#9
0
文件: repo.py 项目: supermihi/exdb
def loadFromXML(creator, number):
    from exdb.exercise import Exercise
    return Exercise.fromXMLFile(xmlPath(creator=creator, number=number))