From 3e1aff21cb6131f52bc4ef17187af665b31654a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Thu, 25 Feb 2010 23:30:22 +0100 Subject: [PATCH 1/1] =?utf8?q?Doda=C5=82em=20"django-nose"=20-=20runner=20?= =?utf8?q?test=C3=B3w=20dla=20nosetest.=20Usun=C4=85=C5=82em=20"piston"=20?= =?utf8?q?z=20listy=20INSTALLED=5FAPPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 ++++++- apps/wiki/models.py | 24 +++++++++++------------- apps/wiki/tests.py | 12 ++++++++++++ apps/wiki/views.py | 19 +++++++++---------- platforma/settings.py | 5 ++++- requirements.txt | 3 ++- 6 files changed, 44 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 9fa4e403..a73fc81d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,9 @@ thumbs.db # Netbeans garbage nbproject -nbproject/* \ No newline at end of file +nbproject/* + +# Eclipse +.project +.pydevproject +.settings diff --git a/apps/wiki/models.py b/apps/wiki/models.py index 7b0f8edc..b4adba4a 100644 --- a/apps/wiki/models.py +++ b/apps/wiki/models.py @@ -3,18 +3,17 @@ import vstorage from vstorage import DocumentNotFound from wiki import settings - class DocumentStorage(object): def __init__(self, path): self.vstorage = vstorage.VersionedStorage(path) - - def get(self, name, revision=None): + + def get(self, name, revision = None): if revision is None: text = self.vstorage.page_text(name) else: text = self.vstorage.revision_text(name, revision) - return Document(self, name=name, text=text) - + return Document(self, name = name, text = text) + def put(self, document, author, comment, parent): self.vstorage.save_text(document.name, document.text, author, comment, parent) @@ -30,24 +29,24 @@ class DocumentStorage(object): class Document(object): META_REGEX = re.compile(r'\s*', re.DOTALL | re.MULTILINE) - + def __init__(self, storage, **kwargs): self.storage = storage for attr, value in kwargs.iteritems(): setattr(self, attr, value) - + def revision(self): try: return self.storage._info(self.name)[0] except DocumentNotFound: - return -1 + return - 1 def plain_text(self): return re.sub(self.META_REGEX, '', self.text, 1) - + def meta(self): result = {} - + m = re.match(self.META_REGEX, self.text) if m: for line in m.group(1).split('\n'): @@ -56,9 +55,8 @@ class Document(object): result[k.strip()] = v.strip() except ValueError: continue - - return result + return result +# Every time somebody says "let's have a global variable", God kills a kitten. storage = DocumentStorage(settings.REPOSITORY_PATH) - diff --git a/apps/wiki/tests.py b/apps/wiki/tests.py index e69de29b..4262d208 100644 --- a/apps/wiki/tests.py +++ b/apps/wiki/tests.py @@ -0,0 +1,12 @@ +import unittest +import wiki.models as models + +class TestDocument(unittest.TestCase): + + def setUp(self): + models.storage = None + + def + + + diff --git a/apps/wiki/views.py b/apps/wiki/views.py index d64a5292..f9e69962 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -8,31 +8,30 @@ from django.utils import simplejson as json from wiki.models import storage, Document, DocumentNotFound from wiki.forms import DocumentForm - -def document_list(request, template_name='wiki/document_list.html'): - return direct_to_template(request, template_name, extra_context={ +def document_list(request, template_name = 'wiki/document_list.html'): + return direct_to_template(request, template_name, extra_context = { 'document_list': storage.all(), }) -def document_detail(request, name, template_name='wiki/document_details.html'): +def document_detail(request, name, template_name = 'wiki/document_details.html'): try: document = storage.get(name) except DocumentNotFound: - document = Document(storage, name=name, text='') - + document = Document(storage, name = name, text = '') + if request.method == 'POST': - form = DocumentForm(request.POST, instance=document) + form = DocumentForm(request.POST, instance = document) if form.is_valid(): document = form.save() return HttpResponse(json.dumps({'text': document.plain_text(), 'meta': document.meta(), 'revision': document.revision()})) else: return HttpResponse(json.dumps({'errors': form.errors})) else: - form = DocumentForm(instance=document) - - return direct_to_template(request, template_name, extra_context={ + form = DocumentForm(instance = document) + + return direct_to_template(request, template_name, extra_context = { 'document': document, 'form': form, }) diff --git a/platforma/settings.py b/platforma/settings.py index 11c2de36..6a1a12ed 100755 --- a/platforma/settings.py +++ b/platforma/settings.py @@ -115,13 +115,16 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.admindocs', + 'django_nose', + 'wiki', - 'piston', 'sorl.thumbnail', 'filebrowser', 'toolbar', ) +TEST_RUNNER = 'django_nose.run_tests' + FILEBROWSER_URL_FILEBROWSER_MEDIA = STATIC_URL + 'filebrowser/' FILEBROWSER_DIRECTORY = 'images/' diff --git a/requirements.txt b/requirements.txt index 56fe4754..076171b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,10 @@ --find-links=http://stigma.nowoczesnapolska.org.pl/pypi/ Django==1.1.1 -lxml==2.2.2 +lxml>=2.2,<2.3 mercurial==1.3.1 librarian>=1.3.dev,<1.4 django-cas-consumer==0.1dev PyYAML>=3.0 MySQL-python>=1.2,<2.0 +django-nose>=0.0.3 -- 2.20.1