def test_listproperty_save_restore(self):
     obj = TestModel()
     obj.xlist = ["foo", "bar", "baz"]
     obj.save()
     tobj = TestModel.get_by_id(obj.key().id())
     self.assertEqual(tobj, obj)
     self.assertEqual(tobj.xlist, ["foo", "bar", "baz"])
Ejemplo n.º 2
0
 def test_filter_unicode(self):  # issue22
     # This test passes with Python >= 2.6 either way.
     obj = TestModel()
     obj.xstring = 'foo'
     obj.save()
     query = db.GqlQuery((u'SELECT * FROM RegressionTestModel'
                          u' WHERE xstring = :foo'), foo=u'foo')
     self.assertEqual(query.count(), 1)
 def test_blobproperty_save_restore(self):
     obj = TestModel()
     obj.blob = db.Blob("test")
     obj.save()
     tobj = TestModel.get_by_id(obj.key().id())
     self.assertEqual(tobj, obj)
     self.assertEqual(obj.blob, "test")
     self.assertEqual(tobj.blob, "test")
     self.assert_(isinstance(tobj.blob, db.Blob))
 def test_auto_current_user_add(self):
     c = Client()
     c.login(username='******', password='******')
     response = c.get('/')
     user = response.context['user']
     self.assert_(user is not None)
     obj = TestModel()
     obj.save()
     self.assertEqual(obj.xuser, user)
 def test_user_property_patched(self):
     c = Client()
     c.login(username='******', password='******')
     response = c.get('/')
     user = response.context['user']
     obj = TestModel()
     obj.save()
     self.assert_(callable(obj.xuser.email))
     self.assert_(hasattr(obj.xuser, 'nickname'))
     self.assert_(callable(obj.xuser.nickname))
Ejemplo n.º 6
0
 def test_user_property_patched(self):
     c = Client()
     c.login(username='******', password='******')
     response = c.get('/')
     user = response.context['user']
     obj = TestModel()
     obj.save()
     self.assert_(callable(obj.xuser.email))
     self.assert_(hasattr(obj.xuser, 'nickname'))
     self.assert_(callable(obj.xuser.nickname))
Ejemplo n.º 7
0
 def test_query_listproperty(self):
     obj = TestModel()
     obj.xlist = ['foo', 'bar', 'baz']
     obj.save()
     query = db.GqlQuery(('SELECT * FROM RegressionTestModel'
                          ' WHERE xlist = :1'), 'foo')
     self.assertEqual([obj], list(query))
     self.assertEqual(query.count(), 1)
     tobj = query.get()
     self.assertEqual(tobj.xlist, ['foo', 'bar', 'baz'])
     query = db.GqlQuery(('SELECT * FROM RegressionTestModel'
                          ' WHERE xlist = :1'), 'nomatch')
     self.assertEqual([], list(query))
     self.assertEqual(query.count(), 0)
     tobj.xlist = ['bar', 'baz']
     tobj.save()
     query = db.GqlQuery(('SELECT * FROM RegressionTestModel'
                          ' WHERE xlist = :1'), 'foo')
     self.assertEqual([], list(query))
     self.assertEqual(query.count(), 0)
Ejemplo n.º 8
0
 def test_query_listproperty(self):
     obj = TestModel()
     obj.xlist = ['foo', 'bar', 'baz']
     obj.save()
     query = db.GqlQuery(('SELECT * FROM RegressionTestModel'
                          ' WHERE xlist = :1'), 'foo')
     self.assertEqual([obj], list(query))
     self.assertEqual(query.count(), 1)
     tobj = query.get()
     self.assertEqual(tobj.xlist, ['foo', 'bar', 'baz'])
     query = db.GqlQuery(('SELECT * FROM RegressionTestModel'
                          ' WHERE xlist = :1'), 'nomatch')
     self.assertEqual([], list(query))
     self.assertEqual(query.count(), 0)
     tobj.xlist = ['bar', 'baz']
     tobj.save()
     query = db.GqlQuery(('SELECT * FROM RegressionTestModel'
                          ' WHERE xlist = :1'), 'foo')
     self.assertEqual([], list(query))
     self.assertEqual(query.count(), 0)
Ejemplo n.º 9
0
 def setUp(self):
     TestModel.objects.all().delete()
     for i in range(10):
         obj = TestModel()
         obj.xstring = 'foo%d' % i
         obj.save()
Ejemplo n.º 10
0
 def test_dbwrite(self):
     # Note: This test mainly makes sense with PostgreSQL backend.
     obj = RegressionTestModel()
     obj.xstring = CallableString(u"möhrenbrei")
     obj.save()