Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added test for setting values via a form POST

  • Loading branch information...
commit 8f90198bcd5656385e4e0014f0ac2f109a79e181 1 parent 7e14e8b
@sneakybeaky authored
Showing with 31 additions and 1 deletion.
  1. +0 −1  test.sh
  2. +2 −0  tests/all_tests.py
  3. +29 −0 tests/test_post_form.py
View
1  test.sh
@@ -140,7 +140,6 @@ fi
#ensure REDIS is running locally
echo "Testing connection to REDIS on $redisipaddress:$redisportnumber..."
-#redis_ping=`redis-cli -h ${redisipaddress} -p ${redisportnumber} PING | grep 'PONG'`
python scripts/ping_redis.py -s ${redisipaddress} -p ${redisportnumber}
OUT=$?
View
2  tests/all_tests.py
@@ -5,6 +5,7 @@
import test_put_get_delete
import test_unicode
import test_jsonp
+import test_post_form
import sys
from test_mod_redis import TestModRedis
@@ -36,6 +37,7 @@ def runTests():
suite.addTests(loader.loadTestsFromModule(test_put_get_delete))
suite.addTests(loader.loadTestsFromModule(test_unicode))
suite.addTests(loader.loadTestsFromModule(test_jsonp))
+ suite.addTests(loader.loadTestsFromModule(test_post_form))
return unittest.TextTestRunner(verbosity=2).run(suite)
View
29 tests/test_post_form.py
@@ -0,0 +1,29 @@
+import test_mod_redis
+import httplib
+import urllib
+
+
+
+class TestPostForm(test_mod_redis.TestModRedis):
+
+ def setUp(self):
+ super(TestPostForm,self).setUp()
+ self.testKey = "testformpost%d" % (self.getNextCounterValue())
+
+ def tearDown(self):
+ self.deleteRedisKey(self.testKey)
+
+ def testPostFormParams(self):
+
+ expectedValue = 'helloworld'
+
+ # Populate the key
+ headers = {"Content-type": "application/x-www-form-urlencoded"}
+ params = urllib.urlencode({'key':self.testKey, 'value': expectedValue})
+ self.connection.request("POST","/redis/poster",params,headers)
+ self.assertXmlResponse(self.connection.getresponse(),{"status":"OK"})
+
+ # Read the key
+ self.connection.request("GET","/redis/%s" % (self.testKey))
+ self.assertXmlResponse(self.connection.getresponse(),{"string":expectedValue})
+
Please sign in to comment.
Something went wrong with that request. Please try again.