From 8adb51c7565b91644c1d8f68e788121f96afe3cf Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Sat, 18 Jul 2015 22:39:47 +0200 Subject: [PATCH] Remove useless assertions --- django_pyvows/assertions/__init__.py | 5 ++- django_pyvows/assertions/urls.py | 54 ---------------------------- django_pyvows/context.py | 9 +---- vows/url_vows.py | 32 ----------------- vows/view_vows.py | 31 ---------------- 5 files changed, 3 insertions(+), 128 deletions(-) delete mode 100644 django_pyvows/assertions/urls.py delete mode 100644 vows/url_vows.py delete mode 100644 vows/view_vows.py diff --git a/django_pyvows/assertions/__init__.py b/django_pyvows/assertions/__init__.py index 27216e8..5e3a4a6 100644 --- a/django_pyvows/assertions/__init__.py +++ b/django_pyvows/assertions/__init__.py @@ -8,6 +8,5 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 Rafael Caricio rafael@caricio.com -from urls import * -from models import * -from templates import * +from models import * # NOQA +from templates import * # NOQA diff --git a/django_pyvows/assertions/urls.py b/django_pyvows/assertions/urls.py deleted file mode 100644 index 2542a85..0000000 --- a/django_pyvows/assertions/urls.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# django-pyvows extensions -# https://github.com/rafaelcaricio/django-pyvows - -# Licensed under the MIT license: -# http://www.opensource.org/licenses/mit-license -# Copyright (c) 2011 Rafael Caricio rafael@caricio.com - -from pyvows import Vows, expect -from django.http import HttpResponse - - -class Url(object): - def __init__(self, context, path): - self.context = context - self.path = path - -@Vows.assertion -def to_be_mapped(topic): - verify_url_is_mapped_to_method(topic) - -@Vows.assertion -def to_match_view(topic, view): - verify_url_is_mapped_to_method(topic, view, True) - -@Vows.assertion -def to_be_http_response(topic): - expect(topic).to_be_instance_of(HttpResponse) - -def verify_url_is_mapped_to_method(topic, method=None, assert_method_as_well=False): - assert isinstance(topic, Url), "Only django_pyvows.Url items can be verified for mapping" - - from django.conf import settings - project_urls = settings.ROOT_URLCONF - - urlpatterns = __import__(project_urls).urls.urlpatterns - - found = False - matches_method = False - for urlpattern in urlpatterns: - regex = urlpattern.regex - pattern = regex.pattern - actual_method = urlpattern.callback - - if topic.path == pattern: - found = True - if method == actual_method: - matches_method = True - - assert found, "Expected url(%s) to be mapped but it wasn't" - if assert_method_as_well: - assert matches_method, "Expected url(%s) to match method(%s), but it didn't" diff --git a/django_pyvows/context.py b/django_pyvows/context.py index 3cc1502..e0ea4a9 100644 --- a/django_pyvows/context.py +++ b/django_pyvows/context.py @@ -12,10 +12,9 @@ import os import django from pyvows import Vows -from django.http import HttpRequest from django_pyvows import http_helpers -from django_pyvows.assertions import Url, Model, Template +from django_pyvows.assertions import Model, Template class DjangoContext(Vows.Context): @@ -44,15 +43,9 @@ class DjangoContext(Vows.Context): from django.test.utils import modify_settings return modify_settings(**kwargs) - def url(self, path): - return Url(self, path) - def template(self, template_name, context): return Template(template_name, context) - def request(self, **kw): - return HttpRequest(**kw) - def model(self, model_class): return Model(self, model_class) diff --git a/vows/url_vows.py b/vows/url_vows.py deleted file mode 100644 index 50134a5..0000000 --- a/vows/url_vows.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# django-pyvows extensions -# https://github.com/rafaelcaricio/django-pyvows - -# Licensed under the MIT license: -# http://www.opensource.org/licenses/mit-license -# Copyright (c) 2011 Rafael Caricio rafael@caricio.com - -from pyvows import expect - -from django_pyvows.context import DjangoContext -from django_pyvows.assertions import * # NOQA - -DjangoContext.start_environment("sandbox.settings") - -from sandbox.main.views import home # NOQA - - -class UrlVows(DjangoContext): - - class Home(DjangoContext): - - def topic(self): - return self.url('^$') - - def should_have_home_url_mapped(self, topic): - expect(topic).to_be_mapped() - - def should_have_url_mapped_to_home_view(self, topic): - expect(topic).to_match_view(home) diff --git a/vows/view_vows.py b/vows/view_vows.py deleted file mode 100644 index 757fe6d..0000000 --- a/vows/view_vows.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# django-pyvows extensions -# https://github.com/rafaelcaricio/django-pyvows - -# Licensed under the MIT license: -# http://www.opensource.org/licenses/mit-license -# Copyright (c) 2011 Rafael Caricio rafael@caricio.com - -from pyvows import Vows, expect -from django_pyvows.context import DjangoContext - -DjangoContext.start_environment("sandbox.settings") - -from sandbox.main.views import home # NOQA - - -@Vows.batch -class ViewVows(DjangoContext): - - class Home(DjangoContext): - - def topic(self): - return home(self.request()) - - def should_be_instance_of_http_response(self, topic): - expect(topic).to_be_http_response() - - def should_be_hello_world(self, topic): - expect(topic).to_have_contents_of('Hello World')