Example #1
0
 def test_save_multivaluefield_with_empty_and_null(self):
     model = TestModel()
     model.multivaluefield = ["1"]
     model.save()
     self.assertEquals(model.multivaluefield, [u"1"])
     self.assertEquals(model.blank_multivaluefield, [])
     self.assertEquals(model.null_multivaluefield, [])
Example #2
0
def index(request):
    test = TestModel()
    test.name = "blah"
    test.save()
	
    result = ""
    for i in TestModel.objects.all():
       result = result + i.name + "<br>";
    return HttpResponse(result)
Example #3
0
 def test_sweeping(self):
     tm = TestModel()
     tm.boolean = False
     tm.characters = 'testing'
     self.assertEqual(tm.get_dirty_fields(), {
         'boolean': True,
         'characters': ''
     })
     tm.save()
     self.assertEqual(tm.get_dirty_fields(), {})
def generate_queries():
    u1 = User.objects.filter()

    new_name = str(random.randint(0, 2000000))
    if u1:
        u1.update(first_name=new_name)
    else:
        u1 = User(username=new_name)
        u1.save()

    u1 = User.objects.filter(username=new_name)
    if u1:
	u1 = u1[0]
        u1.first_name = new_name + 'hello'
        u1.save()

    users = [User(username=get_random_text()) for i in xrange(100)]
    for user in users:
        user.save()
	sleep(5)
	u = User.objects.filter(username=user.username)
	if u.exists():
		username = u[0].username + 'dfas'
		sleep(3)
		u.update(username=username)
    t = TestModel.objects.filter(user=u1)
    t = list(t)

    for i in xrange(100):
        t = TestModel.objects.filter()
        t = list(t)

    for i in xrange(len(users)):
        random_user = random.choice(users)
        t = TestModel(user=random_user)
        t.save()
	sleep(5)

    for i in xrange(100):
        k = TestModel.objects.select_related('user')
        k = list(k)
    tm = TestModel.objects.all()
    for t in tm:
	t.delete()
	sleep(5)
def generate_queries():
    u1 = User.objects.filter()

    new_name = str(random.randint(0, 2000000))
    if u1:
        u1.update(first_name=new_name)
    else:
        u1 = User(username=new_name)
        u1.save()

    u1 = User.objects.filter(username=new_name)
    if u1:
        u1 = u1[0]
        u1.first_name = new_name + 'hello'
        u1.save()

    users = [User(username=get_random_text()) for i in xrange(100)]
    for user in users:
        user.save()
        sleep(5)
        u = User.objects.filter(username=user.username)
        if u.exists():
            username = u[0].username + 'dfas'
            sleep(3)
            u.update(username=username)
    t = TestModel.objects.filter(user=u1)
    t = list(t)

    for i in xrange(100):
        t = TestModel.objects.filter()
        t = list(t)

    for i in xrange(len(users)):
        random_user = random.choice(users)
        t = TestModel(user=random_user)
        t.save()
        sleep(5)

    for i in xrange(100):
        k = TestModel.objects.select_related('user')
        k = list(k)
    tm = TestModel.objects.all()
    for t in tm:
        t.delete()
        sleep(5)
Example #6
0
 def test_lazy(self):
     tm = TestModel()
     tm.save()
Example #7
0
 def test_lazy(self):
     tm = TestModel()
     tm.save()
Example #8
0
File: tests.py Project: bhell/jimi
 def setUp(self):
     a = TestModel(ident=1, price=fields.Money(amount="11.11", currency="USD"))
     a.save()
     b = TestModel(ident=2, price=fields.Money(amount="200.02", currency="USD"))
     b.save()