Skip to content
Browse files

added first test

  • Loading branch information...
1 parent e67cb1c commit af20a4cf062fbf7572869d1954793e6cc2c124a2 Matthew J Morrison committed Oct 23, 2010
Showing with 32 additions and 20 deletions.
  1. +2 −1 .gitignore
  2. 0 src/picoblog/__init__.py
  3. +6 −0 src/picoblog/models.py
  4. +12 −0 src/picoblog/tests.py
  5. +1 −0 src/picoblog/views.py
  6. +8 −7 src/settings.py
  7. +3 −12 src/urls.py
View
3 .gitignore
@@ -5,4 +5,5 @@ parts
develop-eggs
*.egg-info
*.idea
-*~
+*~
+data_db
View
0 src/picoblog/__init__.py
No changes.
View
6 src/picoblog/models.py
@@ -0,0 +1,6 @@
+from django.db import models
+
+class Picoblog(models.Model):
+ @staticmethod
+ def post_message(user, message):
+ Picoblog.objects.create(user=user, message=message)
View
12 src/picoblog/tests.py
@@ -0,0 +1,12 @@
+from django import test
+import mock
+from picoblog.models import Picoblog
+
+class PicoblogTests(test.TestCase):
+
+ @mock.patch('picoblog.models.Picoblog.objects')
+ def should_allow_users_to_post_messages(self, picoblog_mock):
+ Picoblog.post_message("Matt", "Hello")
+ self.assertEqual(((), {'user':'Matt', 'message':'Hello'}),
+ picoblog_mock.create.call_args)
+
View
1 src/picoblog/views.py
@@ -0,0 +1 @@
+# Create your views here.
View
15 src/settings.py
@@ -1,18 +1,20 @@
# Django settings for royalrumble project.
+from unittest import TestLoader
+TestLoader.testMethodPrefix = "should_"
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
- # ('Your Name', 'your_email@domain.com'),
+ ('Matthew J. Morrison', 'mattj.morrison@gmail.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': '', # Or path to database file if using sqlite3.
+ 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+ 'NAME': 'data_db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
@@ -58,12 +60,11 @@
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
-SECRET_KEY = '37hn$xr2w!bwq!cgkv#=#s4d#z)$4^4z!nq%ch$%7(f2y(+_74'
+SECRET_KEY = '3*kj3eor2w!4ag!cgkv#=#s4d#z)$4^*&^nq*dh$%7(f2L#M_74'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
@@ -89,6 +90,6 @@
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
- # Uncomment the next line to enable the admin:
- # 'django.contrib.admin',
+ 'django.contrib.admin',
+ 'picoblog',
)
View
15 src/urls.py
@@ -1,17 +1,8 @@
from django.conf.urls.defaults import *
-# Uncomment the next two lines to enable the admin:
-# from django.contrib import admin
-# admin.autodiscover()
+from django.contrib import admin
+admin.autodiscover()
urlpatterns = patterns('',
- # Example:
- # (r'^royalrumble/', include('royalrumble.foo.urls')),
-
- # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
- # to INSTALLED_APPS to enable admin documentation:
- # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
-
- # Uncomment the next line to enable the admin:
- # (r'^admin/', include(admin.site.urls)),
+ (r'^admin/', include(admin.site.urls)),
)

0 comments on commit af20a4c

Please sign in to comment.
Something went wrong with that request. Please try again.