Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/issue-1310-use-new-message-store
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Jul 29, 2015
2 parents 654cf8e + 86108a9 commit f200d35
Show file tree
Hide file tree
Showing 33 changed files with 245 additions and 794 deletions.
38 changes: 22 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
sudo: false # We want container builds.

language: python
python:
- "2.6"
- "2.7"
node_js:
- "0.10"
env:
- RIAK_VERSION="1.4.12-1" VUMITEST_REDIS_DB=1 VUMIGO_TEST_DB=postgres VUMI_TEST_TIMEOUT=10
## Riak 2.0 sometimes doesn't have enough file descriptors:
## https://github.com/travis-ci/travis-ci/issues/3328
## Until that's fixed, don't build against new Riak.
# matrix:
# include:
# # Test against the Travis-provided version of Riak (currently 2.0.x).
# # This is a separate matrix inclusion to avoid spawning unnecessary builds.
# - python: "2.7"
# env: RIAK_VERSION=current VUMITEST_REDIS_DB=1 VUMIGO_TEST_DB=postgres VUMI_TEST_TIMEOUT=10
- RIAK_VERSION="1.4.12" VUMITEST_REDIS_DB=1 VUMIGO_TEST_DB=postgres VUMI_TEST_TIMEOUT=10
matrix:
include:
# Test against Riak 2.1.1.
# This is a separate matrix inclusion to avoid spawning unnecessary builds.
- python: "2.7"
env: RIAK_VERSION="2.1.1" VUMITEST_REDIS_DB=1 VUMIGO_TEST_DB=postgres VUMI_TEST_TIMEOUT=10

cache:
directories:
- $HOME/.cache/pip
- $HOME/downloads
services:
- postgresql
- redis-server

before_install:
# Set up an appropriate version of Riak.
- sudo utils/setup_travis_riak.sh "${RIAK_VERSION}"
- utils/setup_travis_riak.sh "${RIAK_VERSION}"
install:
# Travis seems to have pip 6.x, which doesn't build and cache wheels.
- "pip install 'pip>=7.1.0'"
- "pip install -r requirements.pip"
- "pip install -r requirements-dev.pip"
- "pip install overalls"
- "npm install"

before_script:
- "psql -c \"create user go with createdb password 'go';\" -U postgres"
- "psql -c 'create database go owner go;' -U postgres"
- "export PYTHONPATH=."
- "django-admin.py syncdb --migrate --noinput --settings=go.testsettings"
- "pip list"
# To see what version of Riak we're running and check that it's happy.
- riak version
- sudo riak-admin member-status
- $HOME/riak/bin/riak version
- $HOME/riak/bin/riak-admin member-status
script:
- ./run-tests.sh
- grunt test
after_script:
- "psql -c 'drop database go;' -U postgres"
- "psql -c 'drop user go;' -U postgres"

after_success:
- overalls --py --lcov mochacov.lcov --lcov coverage/*/lcov.info
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.initConfig({
paths: require('./js_paths.yml'),
paths: require('./go/js_paths.yml'),
bower: {
install: {
options: {
Expand Down
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ include pytest.ini
include tox.ini
include *.sh

# Some non-Python stuff we need.
include go/js_paths.yml
recursive-include go/templates *
recursive-include go/*/templates *
recursive-include go/apps/*/templates *
recursive-include go/fixtures *
recursive-include go/*/fixtures *
recursive-include go/*/static *
recursive-include go/apps *.js

# Prune stray bytecode files.
global-exclude *.pyc
global-exclude __pycache__
2 changes: 1 addition & 1 deletion go/apps/http_api_nostream/vumi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

from go.apps.http_api_nostream.auth import AuthorizedResource
from go.apps.http_api_nostream.resource import ConversationResource
from go.base.utils import extract_auth_from_url
from go.vumitools.app_worker import GoApplicationWorker
from go.vumitools.utils import extract_auth_from_url


# NOTE: Things in this module are subclassed and used by go.apps.http_api.
Expand Down
22 changes: 21 additions & 1 deletion go/apps/jsbox/definition.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import json
from django.template.defaultfilters import slugify
import re
import unicodedata

from go.vumitools.conversation.definition import (
ConversationDefinitionBase, ConversationAction)
from go.apps.jsbox.utils import jsbox_js_config


def slugify(value):
"""
Converts to lowercase, removes non-word characters (alphanumerics and
underscores) and converts spaces to hyphens. Also strips leading and
trailing whitespace.
Borrowed from django.utils.text.slugify() and modified to remove
Django-specific "safe string" code, handle non-unicode input, and be PEP-8
compliant.
"""
if not isinstance(value, unicode):
value = value.decode('utf-8')
value = unicodedata.normalize('NFKD', value)
value = value.encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^\w\s-]', '', value).strip().lower()
return re.sub('[-\s]+', '-', value)


class SendJsboxAction(ConversationAction):
action_name = 'send_jsbox'
action_display_name = 'Trigger push messages'
Expand Down
112 changes: 0 additions & 112 deletions go/base/message_store_client.py

This file was deleted.

20 changes: 2 additions & 18 deletions go/base/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from StringIO import StringIO
from unittest import TestCase


from go.base.tests.helpers import GoDjangoTestCase
import go.base.utils
from go.base.utils import (
get_conversation_view_definition, get_router_view_definition,
UnicodeDictWriter, extract_auth_from_url, sendfile, format_currency)
UnicodeDictWriter, sendfile, format_currency)
from go.errors import UnknownConversationType, UnknownRouterType


Expand Down Expand Up @@ -118,22 +117,7 @@ def test_writerows(self):
rows)


class TestRandomUtils(GoDjangoTestCase):

def test_extract_auth_from_url_no_auth(self):
auth, url = extract_auth_from_url('http://go.vumi.org')
self.assertEqual(auth, None)
self.assertEqual(url, 'http://go.vumi.org')

def test_extract_auth_from_url_with_auth(self):
auth, url = extract_auth_from_url('http://u:p@go.vumi.org')
self.assertEqual(auth, ('u', 'p'))
self.assertEqual(url, 'http://go.vumi.org')

def test_extract_auth_from_url_with_username(self):
auth, url = extract_auth_from_url('http://u@go.vumi.org')
self.assertEqual(auth, ('u', None))
self.assertEqual(url, 'http://go.vumi.org')
class TestSendfile(GoDjangoTestCase):

def test_sendfile(self):
resp = sendfile('/foo')
Expand Down
41 changes: 0 additions & 41 deletions go/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import codecs
from decimal import Decimal, ROUND_DOWN
from StringIO import StringIO
from urlparse import urlparse, urlunparse

from django import forms
from django.http import Http404, HttpResponse
from django.conf import settings
from vumi.persist.redis_manager import RedisManager
Expand Down Expand Up @@ -82,28 +80,6 @@ def padded_queryset(queryset, size=6, padding=None):
return results


def make_read_only_formset(formset):
for form in formset:
make_read_only_form(form)
return formset


def make_read_only_form(form):
"""turn all fields in a form readonly"""
for field_name, field in form.fields.items():
widget = field.widget
if isinstance(
widget, (forms.RadioSelect, forms.CheckboxSelectMultiple)):
widget.attrs.update({
'disabled': 'disabled'
})
else:
widget.attrs.update({
'readonly': 'readonly'
})
return form


def page_range_window(page, padding):
"""
Sometimes the page range is bigger than we're willing to display in the
Expand Down Expand Up @@ -237,23 +213,6 @@ def get_router_view_definition(router_type, router=None):
return router_pkg.view_definition.RouterViewDefinition(router_def)


def extract_auth_from_url(url):
parse_result = urlparse(url)
if parse_result.username:
auth = (parse_result.username, parse_result.password)
url = urlunparse(
(parse_result.scheme,
('%s:%s' % (parse_result.hostname, parse_result.port)
if parse_result.port
else parse_result.hostname),
parse_result.path,
parse_result.params,
parse_result.query,
parse_result.fragment))
return auth, url
return None, url


def format_currency(
value, places=2, rounding=ROUND_DOWN, curr='', sep=',', dp='.', pos='',
neg='-', trailneg=''):
Expand Down
2 changes: 1 addition & 1 deletion go/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required

from go.base.utils import extract_auth_from_url
from go.vumitools.utils import extract_auth_from_url


def todo(request): # pragma: no cover
Expand Down

0 comments on commit f200d35

Please sign in to comment.