Commits

Mikhail Korobov committed e2a365d

Упрощен запуск тестов

  • Participants
  • Parent commits a24d7f6

Comments (0)

Files changed (12)

File yandex_maps/fixtures/yandex_maps.json

-[
-    {
-        "pk": 1, 
-        "model": "yandex_maps.mapandaddress", 
-        "fields": {
-            "latitude": 56.834544999999999, 
-            "longtitude": 60.611083999999998, 
-            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0443\u043b \u041c\u0430\u043b\u044b\u0448\u0435\u0432\u0430, 43"
-        }
-    }, 
-    {
-        "pk": 2, 
-        "model": "yandex_maps.mapandaddress", 
-        "fields": {
-            "latitude": 55.768718999999997, 
-            "longtitude": 37.597422999999999, 
-            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u041c\u043e\u0441\u043a\u0432\u0430 \u0438 \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u041c\u043e\u0441\u043a\u0432\u0430, \u0422\u0432\u0435\u0440\u0441\u043a\u0430\u044f, \u0434\u043e\u043c 27, \u043a\u0432. 25"
-        }
-    }, 
-    {
-        "pk": 3, 
-        "model": "yandex_maps.mapandaddress", 
-        "fields": {
-            "latitude": 56.85371, 
-            "longtitude": 60.604624999999999, 
-            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0430, \u0434. 27"
-        }
-    }, 
-    {
-        "pk": 9, 
-        "model": "yandex_maps.mapandaddress", 
-        "fields": {
-            "latitude": 56.854581000000003, 
-            "longtitude": 60.603825999999998, 
-            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0430, \u0434. 27"
-        }
-    }, 
-    {
-        "pk": 10, 
-        "model": "yandex_maps.mapandaddress", 
-        "fields": {
-            "latitude": 56.832141999999997, 
-            "longtitude": 60.587854, 
-            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u041c\u0430\u043b\u044b\u0448\u0435\u0432\u0430, 12"
-        }
-    }
-]

File yandex_maps/tests.py

-#coding: utf-8
-from generic_utils.test_helpers import ViewTest
-
-class YandexMapTest(ViewTest):
-    
-    fixtures=['yandex_maps']
-
-    def test_views(self):
-        self.check_url('yandex_map', kwargs={'map_id': 1})
-        self.check_url('yandex_map', 404, kwargs={'map_id': 4})
-        

File yandex_maps_tests/__init__.py

Empty file added.

File yandex_maps_tests/manage.py

+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+    import 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(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.exit(1)
+
+if __name__ == "__main__":
+    execute_manager(settings)

File yandex_maps_tests/runtests.py

+#!/usr/bin/env python
+import sys
+from django.core.management import execute_manager
+import settings
+
+sys.argv.insert(1, 'test')
+
+if len(sys.argv) == 2:
+    sys.argv.append('yandex_maps')
+    sys.argv.append('test_app')
+
+if __name__ == "__main__":
+    execute_manager(settings)
+

File yandex_maps_tests/settings.py

+#coding: utf-8
+import os, sys
+PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_ROOT, '..')))
+
+DATABASE_ENGINE = 'sqlite3'
+ROOT_URLCONF = 'urls'
+TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates'),)
+
+YANDEX_MAPS_API_KEY = 'sdfkjhg'
+INSTALLED_APPS=('yandex_maps', 'test_app')

File yandex_maps_tests/templates/404.html

+404

File yandex_maps_tests/test_app/__init__.py

Empty file added.

File yandex_maps_tests/test_app/fixtures/yandex_maps.json

+[
+    {
+        "pk": 1, 
+        "model": "yandex_maps.mapandaddress", 
+        "fields": {
+            "latitude": 56.834544999999999, 
+            "longtitude": 60.611083999999998, 
+            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0443\u043b \u041c\u0430\u043b\u044b\u0448\u0435\u0432\u0430, 43"
+        }
+    }, 
+    {
+        "pk": 2, 
+        "model": "yandex_maps.mapandaddress", 
+        "fields": {
+            "latitude": 55.768718999999997, 
+            "longtitude": 37.597422999999999, 
+            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u041c\u043e\u0441\u043a\u0432\u0430 \u0438 \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u041c\u043e\u0441\u043a\u0432\u0430, \u0422\u0432\u0435\u0440\u0441\u043a\u0430\u044f, \u0434\u043e\u043c 27, \u043a\u0432. 25"
+        }
+    }, 
+    {
+        "pk": 3, 
+        "model": "yandex_maps.mapandaddress", 
+        "fields": {
+            "latitude": 56.85371, 
+            "longtitude": 60.604624999999999, 
+            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0430, \u0434. 27"
+        }
+    }, 
+    {
+        "pk": 9, 
+        "model": "yandex_maps.mapandaddress", 
+        "fields": {
+            "latitude": 56.854581000000003, 
+            "longtitude": 60.603825999999998, 
+            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0430, \u0434. 27"
+        }
+    }, 
+    {
+        "pk": 10, 
+        "model": "yandex_maps.mapandaddress", 
+        "fields": {
+            "latitude": 56.832141999999997, 
+            "longtitude": 60.587854, 
+            "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u041c\u0430\u043b\u044b\u0448\u0435\u0432\u0430, 12"
+        }
+    }
+]

File yandex_maps_tests/test_app/models.py

+#hello, testrunner!

File yandex_maps_tests/test_app/tests.py

+#coding: utf-8
+from django.core.urlresolvers import reverse
+from django.test import TestCase
+
+class YandexMapTest(TestCase):
+    fixtures=['yandex_maps']
+
+    def _check_url(self, url_name, status=200, **kwargs):
+        url = reverse(url_name, kwargs=kwargs)
+        response = self.client.get(url)
+        self.assertEqual(response.status_code, status)
+        return response
+
+    def test_views(self):
+        self._check_url('yandex_map', map_id=1)
+        self._check_url('yandex_map', 404, map_id=4)

File yandex_maps_tests/urls.py

+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+    url(r'^yandex/', include('yandex_maps.urls')),
+)