当前位置: 首页>>代码示例>>Python>>正文


Python RegressionTestModel.delete方法代码示例

本文整理汇总了Python中gae2django.models.RegressionTestModel.delete方法的典型用法代码示例。如果您正苦于以下问题:Python RegressionTestModel.delete方法的具体用法?Python RegressionTestModel.delete怎么用?Python RegressionTestModel.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gae2django.models.RegressionTestModel的用法示例。


在下文中一共展示了RegressionTestModel.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: QueryTest

# 需要导入模块: from gae2django.models import RegressionTestModel [as 别名]
# 或者: from gae2django.models.RegressionTestModel import delete [as 别名]
class QueryTest(unittest.TestCase):

    def setUp(self):
        TestModel.all().delete()
        self.item1 = TestModel(key_name='foo1')
        self.item1.put()

    def tearDown(self):
        self.item1.delete()
        self.item1 = None

    def test_refkey(self):
        # Regression for issue23.
        i1 = TestModel2()
        i1.put()
        i2 = TestModel()
        i2.ref = i1
        i2.put()
        q = TestModel.all()
        q.filter('ref =', i1.key())
        res = list(q.fetch(1000))
        self.assertEqual(len(res), 1)
        self.assertEqual(str(res[0].key()), str(i2.key()))

    def test_key_only(self):
        q = TestModel.all(keys_only=True)
        res = q.fetch(1000)
        self.assertEqual(len(res), 1)
        self.assertEqual(res[0], self.item1.id)
开发者ID:andialbrecht,项目名称:django-gae2django,代码行数:31,代码来源:test_query.py

示例2: test_parent

# 需要导入模块: from gae2django.models import RegressionTestModel [as 别名]
# 或者: from gae2django.models.RegressionTestModel import delete [as 别名]
 def test_parent(self):
     t1 = TestModel(xstring="child", parent=self._test)
     t1.put()
     self.assertEqual(t1.key().parent(), self._key)
     t1.delete()
     t2 = TestModel(xstring="child", parent=self._test_name)
     t2.put()
     self.assertEqual(t2.key().parent(), self._key_name)
     t2.delete()
开发者ID:andialbrecht,项目名称:django-gae2django,代码行数:11,代码来源:test_db.py

示例3: test_get

# 需要导入模块: from gae2django.models import RegressionTestModel [as 别名]
# 或者: from gae2django.models.RegressionTestModel import delete [as 别名]
 def test_get(self):
     item1 = TestModel(key_name='test1')
     item1.put()
     self.assertEqual(TestModel.get('test1'), item1)
     self.assertEqual(TestModel.get('foo'), None)
     self.assertEqual(TestModel.get(['test1', 'test2']), [item1, None])
     item2 = TestModel(key_name='test2')
     item2.put()
     self.assertEqual(TestModel.get(['test1', 'test2']), [item1, item2])
     item1.delete()
     item2.delete()
开发者ID:andialbrecht,项目名称:django-gae2django,代码行数:13,代码来源:test_datastore_model.py

示例4: test_get_by_id

# 需要导入模块: from gae2django.models import RegressionTestModel [as 别名]
# 或者: from gae2django.models.RegressionTestModel import delete [as 别名]
 def test_get_by_id(self):
     item1 = TestModel(xstring='test1')
     item1.put()
     self.assertEqual(TestModel.get_by_id(item1.key().id()), item1)
     self.assertEqual(TestModel.get_by_id(-1), None)
     self.assertEqual(TestModel.get_by_id([item1.key().id(), -1]),
                      [item1, None])
     item2 = TestModel(xstring='test2')
     item2.put()
     self.assertEqual(TestModel.get_by_id([item1.key().id(),
                                           item2.key().id()]),
                      [item1, item2])
     item1.delete()
     item2.delete()
开发者ID:andialbrecht,项目名称:django-gae2django,代码行数:16,代码来源:test_datastore_model.py

示例5: test_get_by_key_name

# 需要导入模块: from gae2django.models import RegressionTestModel [as 别名]
# 或者: from gae2django.models.RegressionTestModel import delete [as 别名]
 def test_get_by_key_name(self):
     self.assertEqual(TestModel.get_by_key_name('foo'), None)
     self.assertEqual(TestModel.get_by_key_name(['foo', 'bar']),
                      [None, None])
     item1 = TestModel(key_name='test1')
     item1.put()
     self.assertEqual(TestModel.get_by_key_name('test1'), item1)
     self.assertEqual(TestModel.get_by_key_name(['test1', 'test2']),
                      [item1, None])
     item2 = TestModel(key_name='test2')
     item2.put()
     self.assertEqual(TestModel.get_by_key_name(['test1', 'test2']),
                      [item1, item2])
     self.assertEqual(TestModel.get_by_key_name(['test1']),
                      [item1])
     item1.delete()
     item2.delete()
开发者ID:andialbrecht,项目名称:django-gae2django,代码行数:19,代码来源:test_datastore_model.py

示例6: DatastoreModelTest

# 需要导入模块: from gae2django.models import RegressionTestModel [as 别名]
# 或者: from gae2django.models.RegressionTestModel import delete [as 别名]
class DatastoreModelTest(unittest.TestCase):

    def setUp(self):
        self.item1 = TestModel(key_name='foo1')
        self.item1.put()

    def tearDown(self):
        self.item1.delete()
        self.item1 = None

    # Class methods

    def test_get(self):
        item1 = TestModel(key_name='test1')
        item1.put()
        self.assertEqual(TestModel.get('test1'), item1)
        self.assertEqual(TestModel.get('foo'), None)
        self.assertEqual(TestModel.get(['test1', 'test2']), [item1, None])
        item2 = TestModel(key_name='test2')
        item2.put()
        self.assertEqual(TestModel.get(['test1', 'test2']), [item1, item2])
        item1.delete()
        item2.delete()

    def test_get_by_id(self):
        item1 = TestModel(xstring='test1')
        item1.put()
        self.assertEqual(TestModel.get_by_id(item1.key().id()), item1)
        self.assertEqual(TestModel.get_by_id(-1), None)
        self.assertEqual(TestModel.get_by_id([item1.key().id(), -1]),
                         [item1, None])
        item2 = TestModel(xstring='test2')
        item2.put()
        self.assertEqual(TestModel.get_by_id([item1.key().id(),
                                              item2.key().id()]),
                         [item1, item2])
        item1.delete()
        item2.delete()


    def test_get_by_key_name(self):
        self.assertEqual(TestModel.get_by_key_name('foo'), None)
        self.assertEqual(TestModel.get_by_key_name(['foo', 'bar']),
                         [None, None])
        item1 = TestModel(key_name='test1')
        item1.put()
        self.assertEqual(TestModel.get_by_key_name('test1'), item1)
        self.assertEqual(TestModel.get_by_key_name(['test1', 'test2']),
                         [item1, None])
        item2 = TestModel(key_name='test2')
        item2.put()
        self.assertEqual(TestModel.get_by_key_name(['test1', 'test2']),
                         [item1, item2])
        self.assertEqual(TestModel.get_by_key_name(['test1']),
                         [item1])
        item1.delete()
        item2.delete()

    def test_get_or_insert(self):
        item1 = TestModel.get_or_insert('test1', xstring='foo')
        self.assert_(isinstance(item1, TestModel))
        test = TestModel.get_or_insert('test1')
        self.assertEqual(item1, test)
        self.assertEqual(item1.xstring, 'foo')
        item1.delete()

    def test_all(self):
        self.assertEqual(len(TestModel.all()), 1)
        item1 = TestModel.get_or_insert('test1')
        self.assertEqual(len(TestModel.all()), 2)
        self.assert_(item1 in TestModel.all())
        item1.delete()

    def test_ancestor(self):
        grandpa = TestModel.get_or_insert('grandpa')
        dad = TestModel.get_or_insert('dad', parent=grandpa)
        TestModel.get_or_insert('junior', parent=dad)
        TestModel.get_or_insert('unrelated')
        q = TestModel.all()
        q.ancestor(grandpa)
        self.assertEqual(len(q), 2)
        q2 = TestModel.all()
        q2.ancestor(dad)
        self.assertEqual(len(q2), 1)
        # ancestor() accepts keys too
        q = TestModel.all()
        q.ancestor(grandpa.key())
        self.assertEqual(len(q), 2)
        q2 = TestModel.all()
        q2.ancestor(dad.key())
        self.assertEqual(len(q2), 1)

    def test_gql(self):
        item1 = TestModel.get_or_insert('test1', xstring='foo')
        item2 = TestModel.get_or_insert('test2', xstring='foo')
        results = TestModel.gql('WHERE xstring = \'foo\'')
        self.assertEqual(results.count(), 2)
        self.assert_(item1 in results)
        self.assert_(item2 in results)
        item1.delete()
#.........这里部分代码省略.........
开发者ID:andialbrecht,项目名称:django-gae2django,代码行数:103,代码来源:test_datastore_model.py

示例7: KeyTest

# 需要导入模块: from gae2django.models import RegressionTestModel [as 别名]
# 或者: from gae2django.models.RegressionTestModel import delete [as 别名]
class KeyTest(unittest.TestCase):

    def setUp(self):
        self._test = TestModel(xstring="foo")
        self._test.put()
        self._key = self._test.key()
        self._test_name = TestModel(xstring="foo", key_name="fookey")
        self._test_name.put()
        self._key_name = self._test_name.key()

    def tearDown(self):
        self._test.delete()
        self._test_name.delete()
        self._test = self._key = None
        self._test_name = self._key_name = None

    # constructor

    def test_constructor(self):
        self.assertRaises(TypeError, db.Key, ('foo',), {'should': 'fail'})
        self.assertRaises(db.BadArgumentError, db.Key, (123,))
        self.assertRaises(db.BadArgumentError, db.Key, (range(2),))

    # class methods

    def test_from_path(self):
        self.assertRaises(db.BadArgumentError, db.Key.from_path,
                          ('foo', 1), should='fail')
        self.assertRaises(db.BadArgumentError, db.Key.from_path,
                          ('foo',))
        self.assertEqual(db.Key.from_path('RegressionTestModel',
                                          self._test.id), self._key)
        k = db.Key.from_path('RegressionTestModel', 'fookey')
        self.assertEqual(db.Key.from_path('RegressionTestModel', 'fookey'),
                         self._key_name)

    # instance methods

    def test_app(self):
        self.assertEqual(self._key.app(), 'gae2django')

    def test_kind(self):
        self.assertEqual(self._key.kind(), 'RegressionTestModel')

    def test_id(self):
        self.assertEqual(self._key.id(), self._test.id)
        self.assertEqual(self._key_name.id(), None)

    def test_name(self):
        self.assertEqual(self._key_name.name(), 'fookey')
        self.assertEqual(self._key.name(), None)

    def test_id_or_name(self):
        self.assertEqual(self._key.id_or_name(), self._test.id)
        self.assertEqual(self._key_name.id_or_name(), 'fookey')

    def test_has_id_or_name(self):
        self.assertEqual(self._key.has_id_or_name(), True)
        self.assertEqual(self._key_name.has_id_or_name(), True)

    def test_parent(self):
        t1 = TestModel(xstring="child", parent=self._test)
        t1.put()
        self.assertEqual(t1.key().parent(), self._key)
        t1.delete()
        t2 = TestModel(xstring="child", parent=self._test_name)
        t2.put()
        self.assertEqual(t2.key().parent(), self._key_name)
        t2.delete()

    # internals

    def test_compare(self):
        # see issue8
        k1 = db.Key('foo1')
        k2 = db.Key('foo1')
        self.assert_(k1 == k2, '%r doesn\'t compare equal to %r' % (k1, k2))
        self.assert_(k2 in set([k1]), 'set comparsion failed')
        self.assert_(not k1 is k2, 'is comparsion failed')

    def test__str__(self):
        k1 = db.Key('foo1')
        self.assertEqual('foo1', str(k1))
开发者ID:andialbrecht,项目名称:django-gae2django,代码行数:85,代码来源:test_db.py


注:本文中的gae2django.models.RegressionTestModel.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。