Skip to content

Commit

Permalink
Merge pull request #27 from mozilla-services/upgrade_cliquet_1.6
Browse files Browse the repository at this point in the history
Upgrade cliquet and add init command to make serve
  • Loading branch information
leplatrem committed May 12, 2015
2 parents 9017ff5 + 01b5eb1 commit 0cf2a44
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 74 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ python: 2.7
sudo: true
services: redis-server
addons:
postgresql: "9.3"
postgresql: "9.4"
env:
- TOX_ENV=py27
- TOX_ENV=py34
Expand All @@ -18,3 +18,7 @@ install:
script:
- if [[ $ACTION != loadtest ]]; then tox -e $TOX_ENV; fi
- if [[ $ACTION == loadtest ]]; then make loadtest-check; fi
after_success:
# Report coverage results to coveralls.io
- pip install coveralls
- coveralls
12 changes: 11 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ This document describes changes between each past release.
0.2.2 (unreleased)
==================

- Nothing changed yet.
- Upgraded to *cliquet* 1.7.0

**Breaking changes**

- PostgreSQL database initialization process is not run automatically in
production. Add this command to deployment procedure:

::

cliquet --ini config/kinto.ini migrate



0.2.1 (2015-03-25)
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ $(PYTHON):
virtualenv $(VENV)

serve: install-dev
$(VENV)/bin/cliquet --ini $(SERVER_CONFIG) migrate
$(VENV)/bin/pserve $(SERVER_CONFIG) --reload

tests-once: install-dev
$(VENV)/bin/nosetests -s --with-mocha-reporter --with-coverage --cover-package=kinto
$(VENV)/bin/nosetests -s --with-mocha-reporter --with-coverage --cover-min-percentage=100 --cover-package=kinto

tests:
tox
Expand Down
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Kinto
=====

|travis| |readthedocs|
|travis| |master-coverage| |readthedocs|

.. |travis| image:: https://travis-ci.org/mozilla-services/kinto.svg?branch=master
:target: https://travis-ci.org/mozilla-services/kinto
Expand All @@ -10,6 +10,11 @@ Kinto
:target: http://kinto.readthedocs.org/en/latest/
:alt: Documentation Status

.. |master-coverage| image::
https://coveralls.io/repos/mozilla-services/kinto/badge.png?branch=master
:alt: Coverage
:target: https://coveralls.io/r/mozilla-services/kinto

Kinto is a server allowing you to store and synchronize arbitrary data,
attached to your Firefox account.

Expand Down
23 changes: 23 additions & 0 deletions app.wsgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
try:
import ConfigParser as configparser
except ImportError:
import configparser
import logging.config
import os

from readinglist import main

here = os.path.dirname(__file__)

ini_path = os.environ.get('KINTO_INI')
if ini_path is None:
ini_path = os.path.join(here, 'config', 'kinto.ini')

# Set up logging
logging.config.fileConfig(ini_path)

# Parse config and create WSGI app
config = configparser.ConfigParser()
config.read(ini_path)

application = main(config.items('DEFAULT'), **dict(config.items('app:main')))
2 changes: 1 addition & 1 deletion config/kinto.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cliquet.retry_after_seconds = 30
cliquet.eos =

pyramid.debug_notfound = true
# cliquet.basic_auth_enabled = true
cliquet.basic_auth_enabled = true
# cliquet.backoff = 10
cliquet.userid_hmac_secret = b4c96a8692291d88fe5a97dd91846eb4
# cliquet.batch_max_requests = 25
Expand Down
1 change: 0 additions & 1 deletion kinto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

# Module version, as defined in PEP-0396.
__version__ = pkg_resources.get_distribution(__package__).version
API_VERSION = "v%s" % __version__.split('.')[0]

# Main kinto logger
logger = logging.getLogger(__name__)
Expand Down
50 changes: 21 additions & 29 deletions kinto/tests/support.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
from cliquet import utils
try:
import unittest2 as unittest
except ImportError:
import unittest # NOQA

from cliquet.tests import support as cliquet_support
import webtest
import kinto


class BaseWebTest(cliquet_support.BaseWebTest):

api_prefix = kinto.API_VERSION

def get_test_app(self):
return webtest.TestApp(kinto.main({}, **self.get_app_settings()))

def get_app_settings(self):
return {
'cliquet.project_name': 'cloud storage',
'cliquet.project_docs': 'https://kinto.rtfd.org/',
'cliquet.basic_auth_enabled': 'true',
'cliquet.userid_hmac_secret': 'b4c96a8692291d88fe5a97dd91846eb4',
'cliquet.storage_backend': 'cliquet.storage.postgresql',
'cliquet.storage_url':
'postgres://postgres:postgres@localhost/testdb',
'cliquet.cache_backend': 'cliquet.cache.redis',
'fxa-oauth.client_id': '89513028159972bc',
'fxa-oauth.client_secret':
'9aced230585cc0aa2932e2eb871c9a3a7d6458'
'e59ccf57eb610ea0a3467dd800',
'fxa-oauth.oauth_uri': 'https://oauth-stable.dev.lcip.org',
'fxa-oauth.scope': 'profile'
}
from cliquet import utils
from cliquet.tests import support as cliquet_support


class BaseWebTest(cliquet_support.FakeAuthentMixin):

app = webtest.TestApp("config:config/kinto.ini",
relative_to='.')

def __init__(self, *args, **kwargs):
super(BaseWebTest, self).__init__(*args, **kwargs)
self.app.RequestClass = cliquet_support.get_request_class(prefix="v0")
self.db = self.app.app.registry.storage
self.db.initialize_schema()
self.headers.update({
'Content-Type': 'application/json',
})

def tearDown(self):
super(BaseWebTest, self).tearDown()
self.db.flush()


def get_user_headers(user):
Expand Down
40 changes: 2 additions & 38 deletions kinto/tests/test_views_hello.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import mock
from webtest.app import TestRequest

from kinto import __version__ as VERSION, API_VERSION
from kinto import __version__ as VERSION

from .support import BaseWebTest, unittest

Expand All @@ -11,40 +8,7 @@ class HelloViewTest(BaseWebTest, unittest.TestCase):
def test_returns_info_about_url_and_version(self):
response = self.app.get('/')
self.assertEqual(response.json['version'], VERSION)
self.assertEqual(response.json['url'], 'http://localhost')
self.assertEqual(response.json['url'], 'http://localhost/v0/')
self.assertEqual(response.json['hello'], 'cloud storage')
self.assertEqual(response.json['documentation'],
'https://kinto.rtfd.org/')

def test_do_not_returns_eos_if_empty_in_settings(self):
response = self.app.get('/')
self.assertNotIn('eos', response.json)

def test_returns_eos_if_not_empty_in_settings(self):
eos = '2069-02-21'
with mock.patch.dict(
self.app.app.registry.settings,
[('cliquet.eos', eos)]):
response = self.app.get('/')
self.assertEqual(response.json['eos'], eos)

def test_redirect_to_version(self):
# We don't want the prefix to be automatically added for this test.
original_request_class = self.app.RequestClass

try:
self.app.RequestClass = TestRequest # Standard RequestClass.

# GET on the hello view.
response = self.app.get('/')
self.assertEqual(response.status_int, 307)
self.assertEqual(response.location,
'http://localhost/%s/' % API_VERSION)

# GET on the fields view.
response = self.app.get('/articles')
self.assertEqual(response.status_int, 307)
self.assertEqual(response.location,
'http://localhost/%s/articles' % API_VERSION)
finally:
self.app.RequestClass = original_request_class
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'cornice',
'six',
'waitress',
'cliquet[postgresql,monitoring] >= 1.4.1'
'cliquet[postgresql,monitoring] >= 1.7.0'
]

ENTRY_POINTS = {
Expand Down

0 comments on commit 0cf2a44

Please sign in to comment.