Esempio n. 1
0
    def test_extends(self):
        with main.app.app_context():
            main.init()
            self.insert_fake_key_list()
            web_interface._add_extend('文档', 'http://www.baidu.com')
            web_interface._add_extend('ss', 'http://www.ee.com')
            c = main.app.test_client()

            res = c.get('/extend')
            res = json.loads(res.data.decode())
            assert len(res['extend']) == 2

            web_interface._delete_extend(1)
            res = c.get('/extend')
            res = json.loads(res.data.decode())
            assert len(res['extend']) == 1

            web_interface._delete_extend(2)
            res = c.get('/extend')
            res = json.loads(res.data.decode())
            assert len(res['extend']) == 0

            web_interface._add_extend('second', 'http://localhost:9001/action')
            res = c.get('/extend')
            res = json.loads(res.data.decode())
            param = dict(
                verify=main.app.config['verify'],
                time=datetime.datetime.now().strftime('%Y-%m-%d %H.%M.%S'),
                data=dict(
                    id=res['extend'][0]['passName'],
                    param='msg=hello'
                )
            )
            res = self.send_request('send_extend', param)
            res = json.loads(res.data.decode())
            assert res.get('status') == 'success'
Esempio n. 2
0
 def test_add_extend(self):
     with main.app.app_context():
         main.init()
         web_interface._add_extend('你好', 'http://www.baidu.com')
         assert db.get_db().execute('select * from Extend').fetchone()['name'] == '你好'