Skip to content

Commit

Permalink
Merge branch 'release/v0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
areski committed Mar 11, 2015
2 parents 5b2f5f2 + fd57019 commit 04783de
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 146 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
@@ -1,22 +1,20 @@
language: python
python:
- "2.5"
- "2.6"
- "2.7"
before_install:
- export PIP_USE_MIRRORS=true
- export PIP_INDEX_URL=https://simple.crate.io/
# - export PIP_INDEX_URL=https://simple.crate.io/
# - sudo apt-get update
install:
- pip install -e .
- pip install -r requirements/tests.txt Django==$DJANGO
- pip install Django==$DJANGO
script:
- make test
env:
- DJANGO=1.3.1
- DJANGO=1.4.13
- DJANGO=1.5.8
- DJANGO=1.6.5
branches:
only:
- develop
- develop
12 changes: 12 additions & 0 deletions Makefile
@@ -1,5 +1,17 @@
#
# Makefile
#

SHELL := /bin/bash
VERSION = $(shell python setup.py --version)

all:
@echo "See Makefile source for targets details"

test:
cd country_dialcode/tests && python runtests.py

oldtest:
flake8 country_dialcode --ignore=E501,E128
coverage run --branch --source=country_dialcode `which django-admin.py` test --settings=country_dialcode.test_settings country_dialcode
coverage report --omit=country_dialcode/test*
6 changes: 0 additions & 6 deletions README.rst
Expand Up @@ -14,12 +14,6 @@ Install Django-Country-Dialcode::
python setup.py install


Dependencies
------------

See requirements.txt file


Settings
========

Expand Down
4 changes: 3 additions & 1 deletion country_dialcode/__init__.py
Expand Up @@ -7,8 +7,10 @@
# :license: MIT, see MIT-LICENSE.txt for more details.
#

__version__ = '0.5.1' # edit also docs/source/conf.py and update requirements.txt
__version__ = '0.6.0' # edit also docs/source/conf.py and update requirements.txt
__author__ = "Arezqui Belaid"
__contact__ = "areski@gmail.com"
__homepage__ = "http://www.areskibelaid.com"
__docformat__ = "restructuredtext"

default_app_config = 'country_dialcode.apps.CountryDialcodeConfig'
8 changes: 3 additions & 5 deletions country_dialcode/admin.py
@@ -1,8 +1,5 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from country_dialcode.models import Country, Prefix
from country_dialcode.app_label_renamer import AppLabelRenamer
AppLabelRenamer(native_app_label=u'country_dialcode', app_label=_('Country Dialcode')).main()


class CountryAdmin(admin.ModelAdmin):
Expand All @@ -21,9 +18,10 @@ class PrefixAdmin(admin.ModelAdmin):
search_fields = ('prefix', 'destination')
list_display = ('prefix', 'destination', 'country_name', 'carrier_name')
ordering = ('prefix', )
#list_filter = ['country_name', 'carrier_name']
# list_filter = ['country_name', 'carrier_name']

def __init__(self, *args, **kwargs):
super(PrefixAdmin, self).__init__(*args, **kwargs)
#self.list_display_links = (None, )
# self.list_display_links = (None, )

admin.site.register(Prefix, PrefixAdmin)
71 changes: 0 additions & 71 deletions country_dialcode/app_label_renamer.py

This file was deleted.

6 changes: 6 additions & 0 deletions country_dialcode/apps.py
@@ -0,0 +1,6 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _


class CountryDialcodeConfig(AppConfig):
verbose_name = _('Country Dialcode')
14 changes: 14 additions & 0 deletions country_dialcode/compatibility.py
@@ -0,0 +1,14 @@
import sys


PY2 = sys.version_info[0] == 2
if not PY2:
text_type = str
binary_type = bytes
string_types = (str,)
integer_types = (int,)
else:
text_type = unicode
binary_type = str
string_types = basestring
integer_types = (int, long)
1 change: 1 addition & 0 deletions country_dialcode/tests/__init__.py
@@ -0,0 +1 @@
from .tests import *
23 changes: 23 additions & 0 deletions country_dialcode/tests/runtests.py
@@ -0,0 +1,23 @@
#!/usr/bin/env python

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'
parent = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

sys.path.insert(0, parent)

from django.test.simple import DjangoTestSuiteRunner


def runtests():
return DjangoTestSuiteRunner(failfast=False).run_tests([
# 'country_dialcode.CountryDialcodeAdminView',
'country_dialcode.CountryDialcodeModel',
], verbosity=1, interactive=True)


if __name__ == '__main__':
if runtests():
sys.exit(1)
48 changes: 48 additions & 0 deletions country_dialcode/tests/test_settings.py
@@ -0,0 +1,48 @@
import os

from country_dialcode.compatibility import text_type


BASE_DIR = os.path.dirname(__file__)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.contenttypes',
'django.contrib.admin',
'country_dialcode',
)

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
}

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
)

ROOT_URLCONF = 'urls'
SECRET_KEY = 'secretkey'
SITE_ROOT = os.path.dirname(os.path.abspath(__file__))


# http://djangosnippets.org/snippets/646/
class InvalidVarException(object):
def __mod__(self, missing):
try:
missing_str = text_type(missing)
except:
missing_str = 'Failed to create string representation'
raise Exception('Unknown template variable %r %s' % (missing, missing_str))

def __contains__(self, search):
if search == '%s':
return True
return False


TEMPLATE_DEBUG = True
TEMPLATE_STRING_IF_INVALID = InvalidVarException()
14 changes: 7 additions & 7 deletions country_dialcode/tests/tests.py
Expand Up @@ -2,11 +2,10 @@

from django.core.management import call_command
from django.test import TestCase
from country_dialcode.utils import BaseAuthenticatedClient
from country_dialcode.models import Country, Prefix


class CountryDialcodeAdminView(BaseAuthenticatedClient):
class CountryDialcodeAdminView(TestCase):
"""Test cases for CountryDialcode Admin Interface."""

def test_admin_country_view_list(self):
Expand Down Expand Up @@ -66,21 +65,22 @@ def setUp(self):
self.prefix = Prefix(
prefix=34,
destination='Spain',
country=self.country,
country_id=self.country,
carrier_name='xyz',
prefix_type=1
)

self.prefix.save()
self.assertEqual(self.prefix.__unicode__(), u'34')

def test_country_prefix_name(self):
self.assertEqual(self.country.countryname, "Spain")
self.assertEqual(self.prefix.country_name, "Spain")
self.assertEqual(self.prefix.country_name(), "Spain")

def teardown(self):
self.country.delete()
self.prefix.delete()

def test_mgt_command(self):
# Test mgt command
call_command('load_country_dialcode')
# def test_mgt_command(self):
# # Test mgt command
# call_command('load_country_dialcode')
31 changes: 31 additions & 0 deletions country_dialcode/tests/utils.py
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-

from django.contrib.auth.models import User
from django.test import TestCase, Client
from django.test.client import RequestFactory
import base64
import unittest


def build_test_suite_from(test_cases):
"""Returns a single or group of unittest test suite(s) that's ready to be
run. The function expects a list of classes that are subclasses of
TestCase.
The function will search the module where each class resides and
build a test suite from that class and all subclasses of it.
"""
test_suites = []
for test_case in test_cases:
mod = __import__(test_case.__module__)
components = test_case.__module__.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
tests = []
for item in mod.__dict__.values():
if type(item) is type and issubclass(item, test_case):
tests.append(item)
test_suites.append(unittest.TestSuite(
map(unittest.TestLoader().loadTestsFromTestCase, tests)))

return unittest.TestSuite(test_suites)
48 changes: 0 additions & 48 deletions country_dialcode/utils.py
@@ -1,56 +1,8 @@
# -*- coding: utf-8 -*-

from django.contrib.auth.models import User
from django.test import TestCase, Client
from django.test.client import RequestFactory
import base64
import unittest
import inspect


def build_test_suite_from(test_cases):
"""Returns a single or group of unittest test suite(s) that's ready to be
run. The function expects a list of classes that are subclasses of
TestCase.
The function will search the module where each class resides and
build a test suite from that class and all subclasses of it.
"""
test_suites = []
for test_case in test_cases:
mod = __import__(test_case.__module__)
components = test_case.__module__.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
tests = []
for item in mod.__dict__.values():
if type(item) is type and issubclass(item, test_case):
tests.append(item)
test_suites.append(unittest.TestSuite(
map(unittest.TestLoader().loadTestsFromTestCase, tests)))

return unittest.TestSuite(test_suites)


class BaseAuthenticatedClient(TestCase):
"""Common Authentication"""
fixtures = ['auth_user.json']

def setUp(self):
"""To create admin user"""
self.client = Client()
self.user = User.objects.get(username='admin')
auth = '%s:%s' % ('admin', 'admin')
auth = 'Basic %s' % base64.encodestring(auth)
auth = auth.strip()
self.extra = {
'HTTP_AUTHORIZATION': auth,
}
login = self.client.login(username='admin', password='admin')
self.assertTrue(login)
self.factory = RequestFactory()


class Choice(object):

class __metaclass__(type):
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Expand Up @@ -48,7 +48,7 @@
# built documents.
#
# The short X.Y version.
version = '0.4'
version = '0.6.0'
# The full version, including alpha/beta/rc tags.
release = '0.4.2'

Expand Down
Empty file removed requirements.txt
Empty file.

0 comments on commit 04783de

Please sign in to comment.