pep8 it
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite://'
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = True
|
||||
PRESERVE_CONTEXT_ON_EXCEPTION = False
|
||||
TESTING=True
|
||||
DEBUG = True
|
||||
TESTING = True
|
||||
DEBUG = True
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import unittest2
|
||||
from api.models import market
|
||||
|
||||
|
||||
class TestMarket(unittest2.TestCase):
|
||||
|
||||
def test_sweden(self):
|
||||
sweden = market.from_territory('SE')
|
||||
self.assertEqual('sv', sweden.language)
|
||||
self.assertEqual('SE', sweden.territory)
|
||||
self.assertEqual('SE', sweden.territory)
|
||||
|
||||
@@ -36,8 +36,10 @@ class TestEndpoints(flask_testing.TestCase):
|
||||
self.assert200(response)
|
||||
|
||||
def test_create_designer(self):
|
||||
data = {'name': 'Spider-Man', 'username': 'spiderman', 'territory': 'US', 'currency': 'USD'}
|
||||
response = self.client.post('/designers/', data=json.dumps(data), content_type='application/json')
|
||||
data = {'name': 'Spider-Man', 'username': 'spiderman',
|
||||
'territory': 'US', 'currency': 'USD'}
|
||||
response = self.client.post(
|
||||
'/designers/', data=json.dumps(data), content_type='application/json')
|
||||
self.assertEqual(201, response.status_code)
|
||||
designer = response.json
|
||||
self.assertEqual('Spider-Man', designer['name'])
|
||||
@@ -45,14 +47,16 @@ class TestEndpoints(flask_testing.TestCase):
|
||||
|
||||
def test_create_designer_missing_data(self):
|
||||
data = {}
|
||||
response = self.client.post('/designers/', data=json.dumps(data), content_type='application/json')
|
||||
response = self.client.post(
|
||||
'/designers/', data=json.dumps(data), content_type='application/json')
|
||||
self.assert400(response)
|
||||
|
||||
@patch('api.tasks.esales.update_designer')
|
||||
def test_update_designer(self, esales_update_designer):
|
||||
designer = self._add_designer('designer1')
|
||||
data = {'name': 'test'}
|
||||
response = self.client.put('/designers/1', data=json.dumps(data), content_type='application/json')
|
||||
response = self.client.put(
|
||||
'/designers/1', data=json.dumps(data), content_type='application/json')
|
||||
self.assertTrue(esales_update_designer.called)
|
||||
self.assertEqual('test', response.json['name'])
|
||||
self.assertEqual('test', Designer.query.get(1).name)
|
||||
self.assertEqual('test', Designer.query.get(1).name)
|
||||
|
||||
@@ -5,8 +5,9 @@ from api.validators import ValidationError, validate_keys_exists
|
||||
class TestValidation(unittest2.TestCase):
|
||||
|
||||
def test_validate_keys_exists(self):
|
||||
obj = {'a':1, 'b':2}
|
||||
obj = {'a': 1, 'b': 2}
|
||||
self.assertRaises(ValidationError, validate_keys_exists, obj, 'c')
|
||||
self.assertRaises(ValidationError, validate_keys_exists, obj, 'a', 'b', 'c')
|
||||
self.assertRaises(
|
||||
ValidationError, validate_keys_exists, obj, 'a', 'b', 'c')
|
||||
self.assertTrue(validate_keys_exists(obj, 'a'))
|
||||
self.assertTrue(validate_keys_exists(obj, 'a', 'b'))
|
||||
|
||||
+3
-2
@@ -16,7 +16,8 @@ class TestHttpBasicAuth(flask_testing.TestCase):
|
||||
self.app.config['API_KEYS'] = [self.api_key]
|
||||
|
||||
def _create_auth_headers(self, username, password=''):
|
||||
data = base64.b64encode(bytes(':'.join([username, password]), 'ascii')).decode('ascii')
|
||||
data = base64.b64encode(
|
||||
bytes(':'.join([username, password]), 'ascii')).decode('ascii')
|
||||
headers = [('Authorization', 'Basic %s' % data)]
|
||||
return headers
|
||||
|
||||
@@ -33,4 +34,4 @@ class TestHttpBasicAuth(flask_testing.TestCase):
|
||||
|
||||
def test_basic_auth_disabled(self):
|
||||
response = self.client.get('/')
|
||||
self.assert200(response)
|
||||
self.assert200(response)
|
||||
|
||||
Reference in New Issue
Block a user