Skip to content

Commit

Permalink
Merge pull request #12 from LegoStormtroopr/cbv
Browse files Browse the repository at this point in the history
fixes some bugs, lets make a new version!
  • Loading branch information
LegoStormtroopr authored Jul 6, 2016
2 parents 8ea3d63 + 692dc46 commit 1493a7c
Show file tree
Hide file tree
Showing 14 changed files with 252 additions and 139 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ env:
install:
# command to install dependencies
- "pip install coveralls"
- pip install pep8
- pip install -q Django==$DJANGO
- "pip install ."
before_script:
- pep8 --ignore=E501,E225,E123 django_spaghetti
- cd docs ; sphinx-build -nW -b html -d _build/doctrees . _build/html ; cd ..
# command to run tests
script:
- coverage run --branch --source=django_spaghetti manage.py test
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ To see a complex example, where ``django-spaghetti-and-meatballs`` really shines
checkout the live version built for the `Aristotle Metadata Registry <http://aristotle.pythonanywhere.com/plate/>`_

.. |docs| image:: https://readthedocs.org/projects/django-spaghetti-and-meatballs/badge/?version=latest
:target: https://readthedocs.org/projects/django-spaghetti-and-meatballs/?badge=latest
:target: https://http://django-spaghetti-and-meatballs.readthedocs.io/en/latest/
:alt: Documentation Status

.. |code-climate| image:: https://codeclimate.com/github/LegoStormtroopr/django-spaghetti-and-meatballs/badges/gpa.svg
Expand Down
5 changes: 3 additions & 2 deletions django_spaghetti/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
__version_info__ = {
'major': 0,
'minor': 2,
'micro': 0,
'micro': 1,
'releaselevel': 'final',
'serial': 0
}


def get_version(release_level=True):
"""
Return the formatted version information
Expand All @@ -15,4 +16,4 @@ def get_version(release_level=True):
vers.append('%(releaselevel)s%(serial)i' % __version_info__)
return ''.join(vers)

__version__ = get_version()
__version__ = get_version()
11 changes: 6 additions & 5 deletions django_spaghetti/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models


class PoliceOfficer(models.Model):
"""
An officer of the NYPD.
Expand All @@ -9,8 +10,7 @@ class PoliceOfficer(models.Model):
first_name = models.CharField(max_length=200)
surname = models.CharField(max_length=200)
rank = models.CharField(max_length=200)

arrests = models.ManyToManyField("Arrest",related_name="arresting_officers")
arrests = models.ManyToManyField("Arrest", related_name="arresting_officers")


class PoliceStation(models.Model):
Expand All @@ -25,11 +25,12 @@ class Precinct(PoliceStation):
number = models.IntegerField(primary_key=True)
burrough = models.CharField(max_length=20)
captain = models.OneToOneField(PoliceOfficer)

class Meta:
unique_together = ("burrough","number")
unique_together = ("burrough", "number")

def natural_key(self):
return (self.burrough,self.number)
return (self.burrough, self.number)


class Division(PoliceStation):
Expand Down
33 changes: 8 additions & 25 deletions django_spaghetti/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'jsut_another_test_key'
SECRET_KEY = 'just_another_test_key'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -26,7 +26,7 @@

ALLOWED_HOSTS = []


TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
# Application definition

INSTALLED_APPS = (
Expand All @@ -37,10 +37,7 @@
'django.contrib.staticfiles',
)

ROOT_URLCONF = 'django_spaghetti.urls'

WSGI_APPLICATION = 'django_spaghetti.tests.wsgi.application'

ROOT_URLCONF = 'django_spaghetti.tests.urls'

# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
Expand All @@ -52,28 +49,14 @@
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL = '/static/'

SPAGHETTI_SAUCE = {
'apps':['tests','auth'], #['tests']
'exclude':{},
'show_fields':False,
'ignore_self_referential':True,
}
'apps': ['tests', 'auth'],
'exclude': {},
'show_fields': False,
'ignore_self_referential': True,
}
Empty file.
17 changes: 15 additions & 2 deletions django_spaghetti/tests/test_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@

setup_test_environment()


class LoadThePlate(TestCase):
def test_plate(self):
home = self.client.get("/")
self.assertEqual(home.status_code,200)
response = self.client.get("/")
self.assertEqual(response.status_code, 200)
self.assertTrue('Officer' in str(response.content))

def test_plate_with_settings(self):
response = self.client.get("/test/plate_settings")
self.assertEqual(response.status_code, 200)
self.assertTrue('Officer' not in str(response.content))

def test_plate_with_override_settings(self):
response = self.client.get("/test/plate_override")
self.assertEqual(response.status_code, 200)
self.assertTrue('policeofficer' in str(response.content).lower())
self.assertTrue('policestation' not in str(response.content).lower())
21 changes: 21 additions & 0 deletions django_spaghetti/tests/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.conf.urls import url, include
from django.contrib import admin
from django_spaghetti.views import plate, Plate

urlpatterns = [
url(r'^test/plate_settings$', Plate.as_view(
settings={
'apps': ['auth'],
'exclude': {},
}
), name='test_plate_settings'),
url(r'^test/plate_override$', Plate.as_view(
override_settings={
'exclude': {
'tests': ['policestation']
},
},
meatball_template_name="tests/meatball.html"
), name='test_plate_override$'),
url(r'^$', include('django_spaghetti.urls', namespace="spaghetti")),
]
14 changes: 0 additions & 14 deletions django_spaghetti/tests/wsgi.py

This file was deleted.

Loading

0 comments on commit 1493a7c

Please sign in to comment.