Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 3 files changed
  • 0 comments
  • 1 contributor
Dec 21, 2012
Nicolas Kuttler Fix #2
Running unit tests from a real project
e7ab49d
Nicolas Kuttler Release 0.1.10 f18203f

Showing 3 changed files with 46 additions and 37 deletions. Show diff stats Hide diff stats

  1. +5 0 README.rst
  2. +1 1  setup.py
  3. +40 36 webmaster_verification/tests.py
5 README.rst
Source Rendered
@@ -74,6 +74,11 @@ should be trivial.
74 74 Changelog
75 75 =========
76 76
  77 +0.1.10 (2012-12-21)
  78 +-------------------
  79 +
  80 +- Fix test errors when running from a real project
  81 +
77 82 0.1.9 (2012-12-19)
78 83 ------------------
79 84
2  setup.py
@@ -5,7 +5,7 @@
5 5
6 6 setup(
7 7 name = "django-webmaster-verification",
8   - version = "0.1.9",
  8 + version = "0.1.10",
9 9 author = "Nicolas Kuttler",
10 10 author_email = "pypi@kuttler.eu",
11 11 description = "Webmaster tools verification for Django",
76 webmaster_verification/tests.py
@@ -9,12 +9,13 @@ def setUp(self):
9 9 self.client = Client()
10 10
11 11 def test_google_file_access_and_content(self):
12   - codes = settings.WEBMASTER_VERIFICATION['google']
13   - if type(codes) == tuple:
14   - for code in codes:
15   - self._test_google_file_access_and_content(code)
16   - else:
17   - self._test_google_file_access_and_content(codes)
  12 + if 'google' in settings.WEBMASTER_VERIFICATION:
  13 + codes = settings.WEBMASTER_VERIFICATION['google']
  14 + if type(codes) == tuple:
  15 + for code in codes:
  16 + self._test_google_file_access_and_content(code)
  17 + else:
  18 + self._test_google_file_access_and_content(codes)
18 19
19 20 def _test_google_file_access_and_content(self, code):
20 21 """
@@ -53,32 +54,34 @@ def _get_google_url(self, code):
53 54 return '/google%s.html' % code
54 55
55 56 def test_bing_file_access_and_content(self):
56   - code = settings.WEBMASTER_VERIFICATION['bing']
57   - url = '/BingSiteAuth.xml'
58   - r = self.client.get(url)
59   - self.assertEqual(
60   - r.status_code,
61   - 200,
62   - "Couldn't access %s, got %d" % (url, r.status_code)
63   - )
64   - self.assertEqual(
65   - r['Content-Type'],
66   - 'text/xml',
67   - "Got %s content type for xml file" % r['Content-Type']
68   - )
69   - self.assertRegexpMatches(
70   - r.content,
71   - '.*%s.*' % code,
72   - 'Verification code not found in response body',
73   - )
  57 + if 'bing' in settings.WEBMASTER_VERIFICATION:
  58 + code = settings.WEBMASTER_VERIFICATION['bing']
  59 + url = '/BingSiteAuth.xml'
  60 + r = self.client.get(url)
  61 + self.assertEqual(
  62 + r.status_code,
  63 + 200,
  64 + "Couldn't access %s, got %d" % (url, r.status_code)
  65 + )
  66 + self.assertEqual(
  67 + r['Content-Type'],
  68 + 'text/xml',
  69 + "Got %s content type for xml file" % r['Content-Type']
  70 + )
  71 + self.assertRegexpMatches(
  72 + r.content,
  73 + '.*%s.*' % code,
  74 + 'Verification code not found in response body',
  75 + )
74 76
75 77 def test_mj_file_access(self):
76   - codes = settings.WEBMASTER_VERIFICATION['majestic']
77   - if type(codes) == tuple:
78   - for code in codes:
79   - self._test_mj_file_access(code)
80   - else:
81   - self._test_mj_file_access(codes)
  78 + if 'majestic' in settings.WEBMASTER_VERIFICATION:
  79 + codes = settings.WEBMASTER_VERIFICATION['majestic']
  80 + if type(codes) == tuple:
  81 + for code in codes:
  82 + self._test_mj_file_access(code)
  83 + else:
  84 + self._test_mj_file_access(codes)
82 85
83 86 def _test_mj_file_access(self, code):
84 87 url = self._get_mj_url(code)
@@ -114,12 +117,13 @@ def _get_mj_url(self, code):
114 117
115 118 # TODO look into refactoring this
116 119 def test_yandex_file_acces(self):
117   - codes = settings.WEBMASTER_VERIFICATION['yandex']
118   - if type(codes) == tuple:
119   - for code in codes:
120   - self._test_yandex_file_access(code)
121   - else:
122   - self._test_yandex_file_access(codes)
  120 + if 'yandex' in settings.WEBMASTER_VERIFICATION:
  121 + codes = settings.WEBMASTER_VERIFICATION['yandex']
  122 + if type(codes) == tuple:
  123 + for code in codes:
  124 + self._test_yandex_file_access(code)
  125 + else:
  126 + self._test_yandex_file_access(codes)
123 127
124 128 # TODO look into refactoring this
125 129 def _test_yandex_file_access(self, code):

No commit comments for this range

Something went wrong with that request. Please try again.