Пример #1
0
 def test_add(self):
     middleware = []
     testApp = TestApp(app.wsgifunc(*middleware))
     key = 'test2'
     message = 'jhfsdf'
     obj_data = {'key': key, 'message': message}
     r1 = testApp.post('/storage/' + key, params=json.dumps(obj_data))
     r = testApp.get('/storage/' + key)
     self.assertEqual(r1.status, 200)
     self.assertEqual(r.status, 200)
     self.assertEqual(json.loads(r.body.decode('utf-8'))['message'], message)
Пример #2
0
    def test_location_post(self):
        middleware = []
        testApp = TestApp(app.wsgifunc(*middleware))

        ap_1 = {"SSID": "MPS01", "level": -67, "BSSID": "b4:b5:2f:4d:51:10"}
        ap_2 = {"SSID": "MPS02", "level": -56, "BSSID": "b4:b5:2f:4d:51:11"}
        ap_3 = {"SSID": "MPS03", "level": -40, "BSSID": "b4:b5:2f:4d:c1:90"}
        ap_4 = {"SSID": "MPS04", "level": -20, "BSSID": "b4:b5:2f:4d:c1:91"}

        # ap_mps01 = {"SSID": "MPS01", "level": -67, "BSSID": "28:2c:b2:5a:8c:be"}
        # ap_mps02 = {"SSID": "MPS02", "level": -56, "BSSID": "28:2c:b2:5a:6b:2c"}
        # ap_43 = {"SSID": "AP43", "level": -40, "BSSID": "b4:b5:2f:4d:c0:20"}

        req = {}
        # req["APInfo"] = [ap_mps01, ap_mps02, ap_43]
        req["APInfo"] = [ap_1, ap_2, ap_3, ap_4]

        r = testApp.post('/location', repr(req))
        assert_equal(r.status, 200)
        r.mustcontain('"Location": "TV"')
Пример #3
0
    def test_location_post(self):
        middleware = []
        testApp = TestApp(app.wsgifunc(*middleware))

        ap_1 = {"SSID": "MPS01", "level": -67, "BSSID": "b4:b5:2f:4d:51:10"}
        ap_2 = {"SSID": "MPS02", "level": -56, "BSSID": "b4:b5:2f:4d:51:11"}
        ap_3 = {"SSID": "MPS03", "level": -40, "BSSID": "b4:b5:2f:4d:c1:90"}
        ap_4 = {"SSID": "MPS04", "level": -20, "BSSID": "b4:b5:2f:4d:c1:91"}

        # ap_mps01 = {"SSID": "MPS01", "level": -67, "BSSID": "28:2c:b2:5a:8c:be"}
        # ap_mps02 = {"SSID": "MPS02", "level": -56, "BSSID": "28:2c:b2:5a:6b:2c"}
        # ap_43 = {"SSID": "AP43", "level": -40, "BSSID": "b4:b5:2f:4d:c0:20"}

        req = {}
        # req["APInfo"] = [ap_mps01, ap_mps02, ap_43]
        req["APInfo"] = [ap_1, ap_2, ap_3, ap_4]

        r = testApp.post('/location', repr(req))
        assert_equal(r.status, 200)
        r.mustcontain('"Location": "TV"')
Пример #4
0
 def test_location_get(self):
     middleware = []
     testApp = TestApp(app.wsgifunc(*middleware))
     r = testApp.get('/location')
     assert_equal(r.status, 200)
     r.mustcontain('hello world!')
Пример #5
0
 def test_notfound(self):
     middleware = []
     testApp = TestApp(app.wsgifunc(*middleware))
     r = testApp.get('/storage/test', status="*")
     self.assertEqual(r.status, 404)
Пример #6
0
 def test_location_get(self):
     middleware = []
     testApp = TestApp(app.wsgifunc(*middleware))
     r = testApp.get('/location')
     assert_equal(r.status, 200)
     r.mustcontain('hello world!')
Пример #7
0
import os, sys

curdir = os.path.dirname(__file__)

if curdir not in sys.path:
    sys.path.append(curdir)

from server import app
import web


sys.stdout = sys.stderr

curdir = os.path.dirname(__file__)
session = web.session.Session(app, web.session.DiskStore(os.path.join(curdir, "sessions.abrad")))

application = app.wsgifunc()