|
|
@ -1,7 +1,6 @@ |
|
|
|
#!/usr/bin/env python |
|
|
|
#!/usr/bin/env python |
|
|
|
# -*- encoding: utf-8 -*- |
|
|
|
# -*- encoding: utf-8 -*- |
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
import tempfile |
|
|
|
import tempfile |
|
|
|
import unittest |
|
|
|
import unittest |
|
|
|
import json |
|
|
|
import json |
|
|
@ -13,17 +12,23 @@ class TestUsers(unittest.TestCase): |
|
|
|
"""Test users request.""" |
|
|
|
"""Test users request.""" |
|
|
|
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
def setUp(self): |
|
|
|
(_, server.app.config['SQLITE_FILENAME']) = tempfile.mkstemp() |
|
|
|
(_, name) = tempfile.mkstemp() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.app.config['SQLITE_FILENAME'] = name |
|
|
|
|
|
|
|
server.app.config['TESTING'] = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print server.app.config['SQLITE_FILENAME'] |
|
|
|
self.app = server.app.test_client() |
|
|
|
self.app = server.app.test_client() |
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self): |
|
|
|
def tearDown(self): |
|
|
|
os.unlick(server.app.config['SQLITE_FILENAME']) |
|
|
|
# os.unlink(server.app.config['SQLITE_FILENAME']) |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def test_create_user(self): |
|
|
|
def test_create_user(self): |
|
|
|
request = {'username': 'username', |
|
|
|
request = {'username': 'username', |
|
|
|
'full_name': 'full name', |
|
|
|
'full_name': 'full name', |
|
|
|
'password': 'hash'} |
|
|
|
'password': 'hash'} |
|
|
|
rv = self.app.put('/users/', |
|
|
|
rv = self.app.put('/user/', |
|
|
|
data=json.dumps(request), |
|
|
|
data=json.dumps(request), |
|
|
|
content_type='application/json') |
|
|
|
content_type='application/json') |
|
|
|
print rv.data |
|
|
|
print rv.data |
|
|
|