Ejemplo n.º 1
0
  def test_find_item(self):
    TestHelper.prepare_sample_database()

    test_id = 5

    dao = TestDao()
    items = dao.find(where_clause=TestEntity.id == test_id)
    self.assertEqual(1, len(items))
    item = items[0]

    self.assertEqual("Test %s" % test_id, item.testName)
    self.assertEqual("This is description %s" % test_id, item.testDescription)
Ejemplo n.º 2
0
  def test_delete_item(self):
    TestHelper.prepare_sample_database()

    test_id = 5

    dao = TestDao()
    items = dao.find(where_clause=TestEntity.id == test_id)
    self.assertEqual(1, len(items))
    item = items[0]

    dao.delete(item)

    items = dao.find(where_clause=TestEntity.id == test_id)
    self.assertEqual(0, len(items))
Ejemplo n.º 3
0
  def test_update_item(self):
    TestHelper.prepare_sample_database()

    test_id = 7

    # check base item
    dao = TestDao()
    items = dao.find(where_clause=TestEntity.id == test_id)
    self.assertEqual(1, len(items))

    item = items[0]
    self.assertEqual("This is description %s" % test_id, item.testDescription)

    # update item
    item.testDescription = "test desc"
    dao.update(item)

    # check update
    items = dao.find(where_clause=TestEntity.id == test_id)
    self.assertEqual(1, len(items))
    item = items[0]
    self.assertEqual("test desc", item.testDescription)