Пример #1
0
    def test_get_context_adds_units_and_errors(self, get_mock):
        view = ActivityView()
        get_mock.return_value = dict(super=sentinel.super)

        # When getting the context data
        context = view.get_context_data()

        # Then the val_errors and units fields are included
        assert context['val_errors'] is not None
        assert context['units'] is not None
        assert context['super'] == sentinel.super
Пример #2
0
    def test_get_object_returns_activity_after_verify(self, get_mock,
                                                      verify_mock):
        # Given a mock parent that returns a mock activity for current user
        view = ActivityView()
        view.request = sentinel.req

        get_mock.return_value = sentinel.activity

        # When getting the object
        activity = view.get_object()

        # Then the mock activity is returned and helper called
        assert activity == sentinel.activity
        verify_mock.assert_called_with(sentinel.activity, sentinel.req)
Пример #3
0
 def setUp(self):
     self.request = RequestFactory().get('activity')
     self.content = Content.objects.create(
         title="Atividades",
         description="foo bar",
         slug="atividades"
     )
     self.activity = Activity.objects.create(
         title="do nothing",
         description="yes, that's a valid activity'",
         slug="do-nothing"
     )
     self.response = ActivityView.as_view()(self.request, slug=self.activity.slug)
Пример #4
0
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

from activities.views import ActivitiesView, ActivityView
from contact.views import ContactView
from index.views import IndexView
from our_installations.views import OurInstallationsView
from partners.views import PartnersView
from social.views import SocialView


admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'atividades/$', ActivitiesView.as_view(), name='activities'),
    url(r'atividades/(?P<slug>[\w-]+)$$', ActivityView.as_view(), name='activity'),
    url(r'nossas-instalacoes/$', OurInstallationsView.as_view(), name='our_installations'),
    url(r'parceiros/$', PartnersView.as_view(), name='partners'),
    url(r'noticias/$', SocialView.as_view(), name='social'),
    url(r'contato/$', ContactView.as_view(), name='contact'),
    url(r'^/?$', IndexView.as_view(), name='index'),

    url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT})
)

urlpatterns += staticfiles_urlpatterns()