Skip to content

Commit

Permalink
Add test project
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Kuttler committed Feb 28, 2012
1 parent ea180a0 commit 520e59a
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
build
dist
*.egg-info
django-webmaster-verification-test-project/db.sqlite
3 changes: 3 additions & 0 deletions Makefile
@@ -1,3 +1,6 @@
test:
make -C django-webmaster-verification-test-project test

install:
python setup.py install

Expand Down
6 changes: 6 additions & 0 deletions django-webmaster-verification-test-project/Makefile
@@ -0,0 +1,6 @@
db.sqlite:
python manage.py syncdb --noinput

.PHONY: test
test: db.sqlite
PYTHONPATH=.. python manage.py test test_app
Empty file.
14 changes: 14 additions & 0 deletions django-webmaster-verification-test-project/manage.py
@@ -0,0 +1,14 @@
#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)

import settings

if __name__ == "__main__":
execute_manager(settings)
22 changes: 22 additions & 0 deletions django-webmaster-verification-test-project/settings.py
@@ -0,0 +1,22 @@
DEBUG = True
TEMPLATE_DEBUG = True

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite',
}
}

ROOT_URLCONF = 'urls'

INSTALLED_APPS = (
'webmaster_verification',
'test_app',
)

WEBMASTER_VERIFICATION = {
'google': 'ffffffffffffffff',
'bing': 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
'majestic': 'ffffffffffffffffffffffffffffffff',
}
Empty file.
3 changes: 3 additions & 0 deletions django-webmaster-verification-test-project/test_app/models.py
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
@@ -0,0 +1 @@
It works!
Empty file.
51 changes: 51 additions & 0 deletions django-webmaster-verification-test-project/test_app/tests.py
@@ -0,0 +1,51 @@
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client

class WebmasterVerificationTest(TestCase):
def setUp(self):
self.client = Client()

def test_google_file_access(self):
url = '/googleffffffffffffffff.html'
r = self.client.get(url)
self.assertEqual(
r.status_code,
200,
"Couldn't access %s, got %d" % (url, r.status_code)
)

def test_bing_file_access(self):
url = '/BingSiteAuth.xml'
r = self.client.get(url)
self.assertEqual(
r.status_code,
200,
"Couldn't access %s, got %d" % (url, r.status_code)
)
self.assertEqual(
r['Content-Type'],
'text/xml',
"Got %s content type for robots.txt" % r['Content-Type']
)

def test_mj_file_access(self):
url = '/MJ12_FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.txt'
r = self.client.get(url)
self.assertEqual(
r.status_code,
200,
"Couldn't access %s, got %d" % (url, r.status_code)
)
self.assertEqual(
r['Content-Type'],
'text/plain',
"Got %s content type for robots.txt" % r['Content-Type']
)

#def test_robotstxt_has_text_plain_content_type(self):
# url = '/robots.txt'
# r = self.client.get(url)
#url = (
# '/BingSiteAuth.xml',
#)
@@ -0,0 +1 @@
# Create your views here.
9 changes: 9 additions & 0 deletions django-webmaster-verification-test-project/urls.py
@@ -0,0 +1,9 @@
from django.conf.urls.defaults import patterns, include, url

from django.views.generic import TemplateView
from webmaster_verification.views import BingVerificationView

urlpatterns = patterns('',
url(r'^x$', TemplateView.as_view(template_name = 'x')),
url(r'', include('webmaster_verification.urls')),
)

0 comments on commit 520e59a

Please sign in to comment.