Skip to content

Commit

Permalink
Adds DCC integration
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Mar 31, 2016
1 parent a50431c commit d56e320
Show file tree
Hide file tree
Showing 17 changed files with 238 additions and 131 deletions.
42 changes: 42 additions & 0 deletions .editorconfig
@@ -0,0 +1,42 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
indent_style = space
indent_size = 4
# isort config
atomic = true
multi_line_output = 5
line_length = 79
combine_as_imports = true
skip = wsgi.py,docs,.tox,env
known_first_party = vies,tests
known_third_party = django


[*.{rst,ini}]
indent_style = space
indent_size = 4

[*.{yml,yaml,html,xml,xsl,json}]
indent_style = space
indent_size = 2

[*.{css,less}]
indent_style = space
indent_size = 2

[*.{js,coffee}]
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab
indent_size = 1
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -5,4 +5,6 @@
.idea/
django_vies.egg-info/
build/
dist/
dist/
.tox/
.cache/
6 changes: 1 addition & 5 deletions .travis.yml
Expand Up @@ -4,14 +4,10 @@ cache:
- pip
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "pypy"
- "pypy3"
env:
matrix:
- DJANGO="Django<1.8,>=1.7"
- DJANGO="Django<1.9,>=1.8"
- DJANGO="-e git+https://github.com/django/django.git@master#egg=Django"
matrix:
Expand All @@ -29,6 +25,6 @@ script:
- isort --check-only --recursive --diff .
- flake8 --jobs=2 .
- pep257
- coverage run --source=vies runtests.py
- coverage run --source=vies -m "pytest"
after_success:
- coveralls
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,23 @@
# Contributing Guide [![badge](https://img.shields.io/badge/Django-CC-ee66dd.svg)][django-cc]
This project follows the **[Django Contributing Commons][django-cc]**.

## Getting started
Getting started is simple, just do:
```bash
pip install dcc
dcc django-vies
hub checkout -b patch-1
```

To test locally simply run:
```bash
tox
```

After that just write your code. Once you are done, just follow this easy flow:
```bash
hub commit
hub pull-request -b codingjoe
```

[django-cc]: https://github.com/codingjoe/django-cc/blob/master/CONTRIBUTING.md
9 changes: 6 additions & 3 deletions README.rst
@@ -1,19 +1,22 @@
.. image:: https://img.shields.io/badge/Django-CC-ee66dd.svg
:target: https://github.com/codingjoe/django-cc

.. image:: https://img.shields.io/pypi/v/django-vies.svg
:target: https://pypi.python.org/pypi/django-vies/

.. image:: https://travis-ci.org/codingjoe/django-vies.png?branch=master
.. image:: https://travis-ci.org/codingjoe/django-vies.svg?branch=master
:target: https://travis-ci.org/codingjoe/django-vies
:alt: Iontinuous Integration

.. image:: https://landscape.io/github/codingjoe/django-vies/master/landscape.svg?style=flat
:target: https://landscape.io/github/codingjoe/django-vies/master
:alt: Code Health

.. image:: https://coveralls.io/repos/codingjoe/django-vies/badge.png?branch=master
.. image:: https://coveralls.io/repos/codingjoe/django-vies/badge.svg?branch=master
:target: https://coveralls.io/r/codingjoe/django-vies
:alt: Test Coverage

.. image:: https://scrutinizer-ci.com/g/codingjoe/django-vies/badges/quality-score.png?b=master
.. image:: https://scrutinizer-ci.com/g/codingjoe/django-vies/badges/quality-score.svg?b=master
:target: https://scrutinizer-ci.com/g/codingjoe/django-vies/?branch=master

.. image:: https://img.shields.io/badge/license-MIT-blue.svg
Expand Down
5 changes: 5 additions & 0 deletions requirements-dev.txt
Expand Up @@ -8,3 +8,8 @@ coverage>=4.0
django-coverage-plugin==1.1
mccabe>=0.3.0
pre-commit>=0.5.5
py==1.4.31
pytest==2.9.1
pytest-django==2.9.1
mock==1.3.0
pbr==1.8.1
46 changes: 0 additions & 46 deletions runtests.py

This file was deleted.

15 changes: 12 additions & 3 deletions setup.cfg
@@ -1,12 +1,18 @@
[pytest]
DJANGO_SETTINGS_MODULE=tests.testapp.settings
norecursedirs=venv env .tox
addopts = --tb=short -rxs

[flake8]
max-line-length = 79
max-complexity = 10
statistics = true
show-source = true
exclude = */migrations/*,docs/*
exclude = */migrations/*,docs/*,env/*,venv/*,.tox/*

[pep257]
ignore = D100,D101,D102,D103,D104,D105,D203
add-ignore = D100,D101,D102,D103,D104,D105
match-dir = (?!tests|env|\.).*

[coverage:run]
source = .
Expand All @@ -16,6 +22,7 @@ omit =
*/migrations/*
*/tests/*
*/test_*.py
.tox

[coverage:report]
ignore_errors = True
Expand All @@ -26,4 +33,6 @@ atomic = true
multi_line_output = 5
line_length = 79
combine_as_imports = true
skip = wsgi.py,docs,runtests.py,setup.py
skip = wsgi.py,docs,tests/test_models.py,.tox,env
known_first_party = vies,tests
known_third_party = django
29 changes: 11 additions & 18 deletions setup.py
@@ -1,25 +1,16 @@
#!/usr/bin/env python
import os
import subprocess
import sys

from setuptools import Command, setup
from setuptools import setup

try:
import django
except ImportError:
django = None

class PyTest(Command):
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
errno = subprocess.call([sys.executable, 'runtests.py'])
raise SystemExit(errno)

if 'sdist' in sys.argv or 'develop' in sys.argv:
if django and ('sdist' in sys.argv or 'develop' in sys.argv):
try:
os.chdir('vies')
from django.core import management
Expand All @@ -33,6 +24,7 @@ def run(self):
description='European VIES VAT field for Django',
author='codingjoe',
url='https://github.com/codingjoe/django-vies',
download_url='https://github.com/codingjoe/django-vies',
author_email='info@johanneshoppe.com',
license='MIT',
classifiers=[
Expand All @@ -48,10 +40,11 @@ def run(self):
'Topic :: Software Development',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: Implementation :: PyPy',
],
packages=['vies'],
include_package_data=True,
install_requires=['suds-jurko>=0.6', 'retrying>=1.1.0'],
cmdclass={'test': PyTest},
install_requires=[
'suds-jurko>=0.6',
'retrying>=1.1.0',
],
)
Empty file added tests/__init__.py
Empty file.
66 changes: 11 additions & 55 deletions vies/tests.py → tests/test_widgets.py
Expand Up @@ -6,68 +6,24 @@
from django import get_version
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import AdminSite
from django.db.models import CharField, Model
from django.forms import Form, ModelForm
from django.utils import unittest
from django.test import TestCase
from mock import patch
from suds import WebFault

from . import VATIN, fields, models
from tests.testapp.forms import (
EmptyVIESModelForm, VIESForm, VIESFormCustomError, VIESFormCustomError16,
VIESModelForm
)
from tests.testapp.models import VIESModel
from vies import VATIN

VALID_VIES = 'DE284754038'
VALID_VIES_COUNTRY_CODE = 'DE'
VALID_VIES_NUMBER = '284754038'
VALID_VIES_IE = ['1234567X', '1X23456X', '1234567XX', ]


class VIESModel(Model):
vat = models.VATINField()


class EmptyVIESModel(Model):
name = CharField(default='John Doe', max_length=50)
vat = models.VATINField(blank=True, null=True)


class VIESModelForm(ModelForm):
class Meta:
model = VIESModel
exclude = []


class EmptyVIESModelForm(ModelForm):
class Meta:
model = EmptyVIESModel
exclude = []


class VIESForm(Form):
vat = fields.VATINField()


class EmptyVIESForm(Form):
vat = fields.VATINField(required=False)


custom_error = {
'invalid_vat': 'This VAT number is not valid'
}


class VIESFormCustomError(Form):
vat = fields.VATINField(error_messages=custom_error)


custom_error_16 = {
'invalid_vat': '%(value)s is not a valid European VAT.'
}


class VIESFormCustomError16(Form):
vat = fields.VATINField(error_messages=custom_error_16)


class VIESTestCase(unittest.TestCase):
class VIESTestCase(TestCase):
def setUp(self):
pass

Expand Down Expand Up @@ -132,7 +88,7 @@ def test_raises_when_suds_web_fault(self, mock_client):
VALID_VIES_NUMBER)


class ModelTestCase(unittest.TestCase):
class ModelTestCase(TestCase):
def setUp(self):
pass

Expand All @@ -153,7 +109,7 @@ def test_save(self):
self.assertEqual(vies_received.vat, VALID_VIES)


class ModelFormTestCase(unittest.TestCase):
class ModelFormTestCase(TestCase):
def test_is_valid(self):
"""Form is valid."""
form = VIESModelForm({
Expand Down Expand Up @@ -238,7 +194,7 @@ class MockRequest(object):
request = MockRequest()


class AdminTestCase(unittest.TestCase):
class AdminTestCase(TestCase):
def setUp(self):
self.site = AdminSite()

Expand Down
Empty file added tests/testapp/__init__.py
Empty file.

0 comments on commit d56e320

Please sign in to comment.