edsu committed f8b9179

added a test to make sure adding bookmarks works

Comments (0)

Files changed (4)


+[{"pk": 5, "model": "contenttypes.contenttype", "fields": {"model": "contenttype", "name": "content type", "app_label": "contenttypes"}}, {"pk": 15, "model": "contenttypes.contenttype", "fields": {"model": "entry", "name": "entry", "app_label": "base"}}, {"pk": 13, "model": "contenttypes.contenttype", "fields": {"model": "entrytag", "name": "entry tag", "app_label": "base"}}, {"pk": 11, "model": "contenttypes.contenttype", "fields": {"model": "filter", "name": "filter", "app_label": "base"}}, {"pk": 2, "model": "contenttypes.contenttype", "fields": {"model": "group", "name": "group", "app_label": "auth"}}, {"pk": 9, "model": "contenttypes.contenttype", "fields": {"model": "groupprofile", "name": "group profile", "app_label": "base"}}, {"pk": 8, "model": "contenttypes.contenttype", "fields": {"model": "logentry", "name": "log entry", "app_label": "admin"}}, {"pk": 4, "model": "contenttypes.contenttype", "fields": {"model": "message", "name": "message", "app_label": "auth"}}, {"pk": 1, "model": "contenttypes.contenttype", "fields": {"model": "permission", "name": "permission", "app_label": "auth"}}, {"pk": 6, "model": "contenttypes.contenttype", "fields": {"model": "session", "name": "session", "app_label": "sessions"}}, {"pk": 7, "model": "contenttypes.contenttype", "fields": {"model": "site", "name": "site", "app_label": "sites"}}, {"pk": 12, "model": "contenttypes.contenttype", "fields": {"model": "tag", "name": "tag", "app_label": "base"}}, {"pk": 14, "model": "contenttypes.contenttype", "fields": {"model": "url", "name": "url", "app_label": "base"}}, {"pk": 3, "model": "contenttypes.contenttype", "fields": {"model": "user", "name": "user", "app_label": "auth"}}, {"pk": 10, "model": "contenttypes.contenttype", "fields": {"model": "userprofile", "name": "user profile", "app_label": "base"}}, {"pk": 1, "model": "", "fields": {"domain": "", "name": ""}}, {"pk": 1, "model": "base.userprofile", "fields": {"tz": "", "date_modified": "2010-12-17 09:42:14", "url": "", "default_to_private_entry": false, "token": "", "group_invites": [], "user": 1, "is_private": false}}, {"pk": 22, "model": "auth.permission", "fields": {"codename": "add_logentry", "name": "Can add log entry", "content_type": 8}}, {"pk": 23, "model": "auth.permission", "fields": {"codename": "change_logentry", "name": "Can change log entry", "content_type": 8}}, {"pk": 24, "model": "auth.permission", "fields": {"codename": "delete_logentry", "name": "Can delete log entry", "content_type": 8}}, {"pk": 4, "model": "auth.permission", "fields": {"codename": "add_group", "name": "Can add group", "content_type": 2}}, {"pk": 5, "model": "auth.permission", "fields": {"codename": "change_group", "name": "Can change group", "content_type": 2}}, {"pk": 6, "model": "auth.permission", "fields": {"codename": "delete_group", "name": "Can delete group", "content_type": 2}}, {"pk": 10, "model": "auth.permission", "fields": {"codename": "add_message", "name": "Can add message", "content_type": 4}}, {"pk": 11, "model": "auth.permission", "fields": {"codename": "change_message", "name": "Can change message", "content_type": 4}}, {"pk": 12, "model": "auth.permission", "fields": {"codename": "delete_message", "name": "Can delete message", "content_type": 4}}, {"pk": 1, "model": "auth.permission", "fields": {"codename": "add_permission", "name": "Can add permission", "content_type": 1}}, {"pk": 2, "model": "auth.permission", "fields": {"codename": "change_permission", "name": "Can change permission", "content_type": 1}}, {"pk": 3, "model": "auth.permission", "fields": {"codename": "delete_permission", "name": "Can delete permission", "content_type": 1}}, {"pk": 7, "model": "auth.permission", "fields": {"codename": "add_user", "name": "Can add user", "content_type": 3}}, {"pk": 8, "model": "auth.permission", "fields": {"codename": "change_user", "name": "Can change user", "content_type": 3}}, {"pk": 9, "model": "auth.permission", "fields": {"codename": "delete_user", "name": "Can delete user", "content_type": 3}}, {"pk": 43, "model": "auth.permission", "fields": {"codename": "add_entry", "name": "Can add entry", "content_type": 15}}, {"pk": 44, "model": "auth.permission", "fields": {"codename": "change_entry", "name": "Can change entry", "content_type": 15}}, {"pk": 45, "model": "auth.permission", "fields": {"codename": "delete_entry", "name": "Can delete entry", "content_type": 15}}, {"pk": 37, "model": "auth.permission", "fields": {"codename": "add_entrytag", "name": "Can add entry tag", "content_type": 13}}, {"pk": 38, "model": "auth.permission", "fields": {"codename": "change_entrytag", "name": "Can change entry tag", "content_type": 13}}, {"pk": 39, "model": "auth.permission", "fields": {"codename": "delete_entrytag", "name": "Can delete entry tag", "content_type": 13}}, {"pk": 31, "model": "auth.permission", "fields": {"codename": "add_filter", "name": "Can add filter", "content_type": 11}}, {"pk": 32, "model": "auth.permission", "fields": {"codename": "change_filter", "name": "Can change filter", "content_type": 11}}, {"pk": 33, "model": "auth.permission", "fields": {"codename": "delete_filter", "name": "Can delete filter", "content_type": 11}}, {"pk": 25, "model": "auth.permission", "fields": {"codename": "add_groupprofile", "name": "Can add group profile", "content_type": 9}}, {"pk": 26, "model": "auth.permission", "fields": {"codename": "change_groupprofile", "name": "Can change group profile", "content_type": 9}}, {"pk": 27, "model": "auth.permission", "fields": {"codename": "delete_groupprofile", "name": "Can delete group profile", "content_type": 9}}, {"pk": 34, "model": "auth.permission", "fields": {"codename": "add_tag", "name": "Can add tag", "content_type": 12}}, {"pk": 35, "model": "auth.permission", "fields": {"codename": "change_tag", "name": "Can change tag", "content_type": 12}}, {"pk": 36, "model": "auth.permission", "fields": {"codename": "delete_tag", "name": "Can delete tag", "content_type": 12}}, {"pk": 40, "model": "auth.permission", "fields": {"codename": "add_url", "name": "Can add url", "content_type": 14}}, {"pk": 41, "model": "auth.permission", "fields": {"codename": "change_url", "name": "Can change url", "content_type": 14}}, {"pk": 42, "model": "auth.permission", "fields": {"codename": "delete_url", "name": "Can delete url", "content_type": 14}}, {"pk": 28, "model": "auth.permission", "fields": {"codename": "add_userprofile", "name": "Can add user profile", "content_type": 10}}, {"pk": 29, "model": "auth.permission", "fields": {"codename": "change_userprofile", "name": "Can change user profile", "content_type": 10}}, {"pk": 30, "model": "auth.permission", "fields": {"codename": "delete_userprofile", "name": "Can delete user profile", "content_type": 10}}, {"pk": 13, "model": "auth.permission", "fields": {"codename": "add_contenttype", "name": "Can add content type", "content_type": 5}}, {"pk": 14, "model": "auth.permission", "fields": {"codename": "change_contenttype", "name": "Can change content type", "content_type": 5}}, {"pk": 15, "model": "auth.permission", "fields": {"codename": "delete_contenttype", "name": "Can delete content type", "content_type": 5}}, {"pk": 16, "model": "auth.permission", "fields": {"codename": "add_session", "name": "Can add session", "content_type": 6}}, {"pk": 17, "model": "auth.permission", "fields": {"codename": "change_session", "name": "Can change session", "content_type": 6}}, {"pk": 18, "model": "auth.permission", "fields": {"codename": "delete_session", "name": "Can delete session", "content_type": 6}}, {"pk": 19, "model": "auth.permission", "fields": {"codename": "add_site", "name": "Can add site", "content_type": 7}}, {"pk": 20, "model": "auth.permission", "fields": {"codename": "change_site", "name": "Can change site", "content_type": 7}}, {"pk": 21, "model": "auth.permission", "fields": {"codename": "delete_site", "name": "Can delete site", "content_type": 7}}, {"pk": 1, "model": "auth.user", "fields": {"username": "unalog", "first_name": "", "last_name": "", "is_active": true, "is_superuser": true, "is_staff": true, "last_login": "2010-12-17 09:42:14", "groups": [], "user_permissions": [], "password": "sha1$09dce$08819bd241680d01bc650c74e7a5c8526a2235ea", "email": "", "date_joined": "2010-12-17 09:42:14"}}]
 # users don't automatically get one, but everyone has to have one.
 def user_post_save_create_profile (sender, **kwargs):
     if kwargs['created']:
-        up = UserProfile(user=kwargs['instance'])
+        UserProfile.objects.get_or_create(user=kwargs['instance'])
 post_save.connect(user_post_save_create_profile, User)
+For these tests to run you'll need to run a test solr instance on a port 9999 
+so that you don't stomp on your real production solr.
+    java -Djetty.port=9999 -DSTOP.PORT=9998 -jar start.jar
+from django.test import TestCase, Client
+from django.conf import settings
+from unalog2.base import models as m
+class UnalogTests(TestCase):
+    fixtures = ['test_account.json']
+    settings.SOLR_URL = "http://localhost:9999/solr"
+    def test_add_entry(self):
+        client = Client()
+        self.assertTrue(client.login(username='unalog', password='unalog'))
+        entry = {
+                    'url':          '',
+                    'title':        'hey!',
+                    'is_private':   False,
+                    'tags':         'unalog yeah',
+                    'comment':      'this is just an example see?',
+                    'content':      'example yeah! example yeah!',
+                    'submit':       None
+                }
+        response ='/entry/new', entry)
+        self.assertEqual(response['location'], 'http://testserver/entry/1/edit/')
+        entry = m.Entry.objects.get(id=1)
+        self.assertEqual(entry.url.value, '')
+        self.assertEqual(entry.title, 'hey!')
+        self.assertEqual(entry.is_private, False)
+        self.assertEqual(entry.comment, 'this is just an example see?')
+        self.assertEqual(entry.content, 'example yeah! example yeah!')
+        entry_tags = entry.tags.all()
+        self.assertEqual(len(entry_tags), 2)
+        self.assertEqual(entry_tags[0], 'unalog')
+        self.assertEqual(entry_tags[1], 'yeah')
-DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = ''             # Or path to database file if using sqlite3.
+DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = 'unalog2'             # Or path to database file if using sqlite3.
 DATABASE_USER = ''             # Not used with sqlite3.
 DATABASE_PASSWORD = ''         # Not used with sqlite3.
 DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.