Beispiel #1
0
class DBTestCase(unittest.TestCase):

        Benchmark.enabled = True
        Benchmark.categories = set(['SET', 'GET'])

        def setUp(self):
                print

                self.db = DB()
                self.db.path = os.environ['ELROND_DB']
                self.db.name = 'elrond.db'
                self.db.open()

        def tearDown(self):
                self.db.close()

        def testDB(self):
                name = u'Guido von Rossum'

                @Benchmark(category=['SET'])
                def testSet(name):
                        person = Person()
                        person.name = name

                        self.db.add(person)
                        self.db.save()

                @Benchmark(category=['GET'])
                def testGet():
                        return self.db.query(Person, Person.name == name)[0].name

                testSet(name)
                self.assertEqual(name, testGet())
Beispiel #2
0
        def setUp(self):
                print

                self.db = DB()
                self.db.path = os.environ['ELROND_DB']
                self.db.name = 'elrond.db'
                self.db.open()