Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
head fork: andreysobol/42test
  • 6 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 11, 2012
@andreysobol many fixes b3899d7
@andreysobol Merge branch 't1_show_bio' into t2_request_middleware
Conflicts:
	testsobol/mainapp/tests.py
	testsobol/mainapp/views.py
	testsobol/urls.py
c980321
@andreysobol ticket3: pep8, named url, 10 first, test <10 request c52e8b2
@andreysobol Merge branch 't2_request_middleware' into t4_settings_in_context
Conflicts:
	testsobol/mainapp/tests.py
bfa1afd
@andreysobol ticket4: pep8, fix test context 512e72f
@andreysobol Merge branch 't4_settings_in_context' into t5_forms_and_auth
Conflicts:
	testsobol/mainapp/models.py
	testsobol/mainapp/tests.py
	testsobol/mainapp/views.py
	testsobol/templates/index.html
	testsobol/urls.py
3a44bf4
View
2  testsobol/Makefile
@@ -0,0 +1,2 @@
+test:
+ python manage.py test mainapp
View
3  testsobol/mainapp/context_processor.py
@@ -1,4 +1,5 @@
from django.conf import settings
+
def settings_context_processor(request):
- return {'settings':settings}
+ return {'settings': settings}
View
3  testsobol/mainapp/middleware.py
@@ -2,8 +2,9 @@
from models import Request
+
class RequestMiddleware(object):
-
+
def process_request(self, request):
r = Request()
r.date = datetime.now()
View
1  testsobol/mainapp/models.py
@@ -20,6 +20,7 @@ def render(self):
return self.get_struct(get)
+
class Request(models.Model):
date = models.DateTimeField()
url = models.CharField(max_length=250)
View
31 testsobol/mainapp/tests.py
@@ -15,8 +15,6 @@
class IndexViewTest(TestCase):
def test(self):
- fixtures = ['initial_data.json']
-
page = self.client.get('')
self.assertEqual(page.status_code, 200)
@@ -30,7 +28,11 @@ class RequestTest(TestCase):
def test(self):
page = self.client.get('')
- self.assertTrue(bool(Request.objects.filter(date__gte = (datetime.now() - timedelta(minutes=1)))))
+
+ self.assertEqual(page.status_code, 200)
+
+ self.assertTrue(bool(Request.objects.filter(
+ date__gte=(datetime.now() - timedelta(minutes=1)))))
class RequestViewTest(TestCase):
@@ -40,12 +42,14 @@ def test(self):
self.assertEqual(page.status_code, 200)
self.assertTrue(bool(page.context['request']))
+
class SettingsContextTest(TestCase):
-
+
def test(self):
page = self.client.get('')
self.assertEqual(page.status_code, 200)
self.assertTrue(page.context['settings'])
+ self.assertEqual(page.context['settings'].STATIC_URL, '/static/')
class Edit(TestCase):
@@ -63,3 +67,22 @@ def test(self):
page = self.client.post('/edit/', {"bio": "Noooooooooooooo", "surname": "Sobol", "name": "Andrey", "other": "pigeon post - white pigeon only"})
self.assertEqual(page.status_code, 200)
self.assertTrue(page.content.find("error") != -1)
+
+
+class NameUrlTest(TestCase):
+
+ def test(self):
+ page = self.client.get('/')
+ self.assertEqual(page.status_code, 200)
+ self.assertTrue(page.content.find('a href="/http/"') != -1)
+
+
+class ManyRequestTest(TestCase):
+
+ def test(self):
+ for t in range(11):
+ page = self.client.get('/')
+ self.assertEqual(page.status_code, 200)
+
+ page = self.client.get('/http/')
+ self.assertTrue(page.context['request'].count() == 10)
View
5 testsobol/mainapp/views.py
@@ -8,12 +8,13 @@
from models import Bio, Request
from forms import BioForm
+
class Index(TemplateView):
template_name = 'index.html'
def get_context_data(self, **kwargs):
- context = super(Index, self).get_context_data(**kwargs)
+ super(Index, self).get_context_data(**kwargs)
return {'renders':Bio.objects.get(pk = 1).render()}
@@ -52,4 +53,4 @@ class Http(ListView):
paginate_by = 10
def get_queryset(self):
- return Request.objects.order_by('-date')
+ return Request.objects.order_by('date')
View
12 testsobol/settings.py
@@ -13,12 +13,12 @@
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': 'db.sqlite3', # 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.
- 'PORT': '', # Set to empty string for default. Not used with sqlite3.
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'db.sqlite3',
+ 'USER': '',
+ 'PASSWORD': '',
+ 'HOST': '',
+ 'PORT': '',
}
}
View
2  testsobol/templates/index.html
@@ -51,7 +51,7 @@
{% else %}
<a href="/edit/">login and edit</a>
{% endif %}
- <a href="/http/">request</a>
+ <a href="{% url http %}">request</a>
</div>
{% endif %}
{% endblock %}
View
4 testsobol/urls.py
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import patterns, include, url
+from django.conf.urls.defaults import patterns, url
from django.conf import settings
from testsobol.mainapp.views import Index, Http, Edit
@@ -10,7 +10,7 @@
# Examples:
url(r'^$', Index.as_view()),
url(r'^edit/$', Edit.as_view()),
- url(r'^http/$', Http.as_view()),
+ url(r'^http/$', Http.as_view(), name="http"),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
(r'^accounts/login/$', 'django.contrib.auth.views.login', { "template_name": "admin/login.html" } ),

No commit comments for this range

Something went wrong with that request. Please try again.