def test_format_is_included(self): router = SubRouterWithFormat() router.register('foo', ModelViewSet, base_name='bar') expected = [ { 'name': 'bar-list', 'pattern': '^(?P<pk>[^/]+)/foo/$' }, { 'name': 'bar-detail', 'pattern': '^(?P<pk>[^/]+)/foo/$' }, { 'name': 'bar-list', 'pattern': '^(?P<pk>[^/.]+)/foo\\.(?P<format>[a-z0-9]+)$' }, { 'name': 'bar-detail', 'pattern': '^(?P<pk>[^/.]+)/foo\\.(?P<format>[a-z0-9]+)$' }, ] actual = [{ 'name': url.name, 'pattern': url.regex.pattern } for url in router.urls] for i, _ in enumerate(expected): eq_(actual[i], expected[i])
def test_format_is_included_no_trailing_slashes(self): router = SubRouterWithFormat(trailing_slash=False) router.register('foo', ModelViewSet, base_name='bar') expected = [ {'name': 'bar-list', 'pattern': '^(?P<pk>[^/.]+)/foo$'}, {'name': 'bar-detail', 'pattern': '^(?P<pk>[^/.]+)/foo$'}, {'name': 'bar-list', 'pattern': '^(?P<pk>[^/.]+)/foo\\.(?P<format>[a-z0-9]+)$'}, {'name': 'bar-detail', 'pattern': '^(?P<pk>[^/.]+)/foo\\.(?P<format>[a-z0-9]+)$'}, ] actual = [{ 'name': url.name, 'pattern': url.regex.pattern } for url in router.urls] for i, _ in enumerate(expected): eq_(actual[i], expected[i])
from mkt.api.base import SubRouterWithFormat from mkt.api.v1.urls import urlpatterns as v1_urls from mkt.api.views import endpoint_removed from mkt.search.views import RocketbarViewV2 feed = SimpleRouter() feed.register(r'apps', views.FeedAppViewSet, base_name='feedapps') feed.register(r'brands', views.FeedBrandViewSet, base_name='feedbrands') feed.register(r'collections', views.FeedCollectionViewSet, base_name='feedcollections') feed.register(r'shelves', views.FeedShelfViewSet, base_name='feedshelves') feed.register(r'items', views.FeedItemViewSet, base_name='feeditems') subfeedapp = SubRouterWithFormat() subfeedapp.register('image', views.FeedAppImageViewSet, base_name='feed-app-image') subfeedcollection = SubRouterWithFormat() subfeedcollection.register('image', views.FeedCollectionImageViewSet, base_name='feed-collection-image') subfeedshelf = SubRouterWithFormat() subfeedshelf.register('image', views.FeedShelfImageViewSet, base_name='feed-shelf-image') urlpatterns = patterns('', url(r'^apps/search/rocketbar/', RocketbarViewV2.as_view(), name='rocketbar-search-api'), url(r'^rocketfuel/collections/.*', endpoint_removed), url(r'^feed/builder/$', views.FeedBuilderView.as_view(), name='feed.builder'),
RocketbarViewV2) from mkt.websites.views import (WebsiteMetadataScraperView, WebsiteSearchView, WebsiteView, WebsiteSubmissionViewSet) feed = SimpleRouter() feed.register(r'apps', views.FeedAppViewSet, base_name='feedapps') feed.register(r'brands', views.FeedBrandViewSet, base_name='feedbrands') feed.register(r'collections', views.FeedCollectionViewSet, base_name='feedcollections') feed.register(r'shelves', views.FeedShelfViewSet, base_name='feedshelves') feed.register(r'items', views.FeedItemViewSet, base_name='feeditems') subfeedapp = SubRouterWithFormat() subfeedapp.register('image', views.FeedAppImageViewSet, base_name='feed-app-image') subfeedcollection = SubRouterWithFormat() subfeedcollection.register('image', views.FeedCollectionImageViewSet, base_name='feed-collection-image') subfeedshelf = SubRouterWithFormat() subfeedshelf.register('image', views.FeedShelfImageViewSet, base_name='feed-shelf-image') subfeedshelf.register('image_landing', views.FeedShelfLandingImageViewSet, base_name='feed-shelf-landing-image')
from mkt.developers.urls import dev_api_patterns, payments_api_patterns from mkt.features.views import AppFeaturesList from mkt.receipts.urls import receipt_api_patterns from mkt.reviewers.urls import api_patterns as reviewer_api_patterns from mkt.search.views import (FeaturedSearchView, RocketbarView, SearchView, SuggestionsView) from mkt.stats.urls import stats_api_patterns, txn_api_patterns from mkt.submit.views import PreviewViewSet, StatusViewSet, ValidationViewSet from mkt.webapps.views import AppTagViewSet, AppViewSet, PrivacyPolicyViewSet rocketfuel = SimpleRouter() rocketfuel.register(r'collections', CollectionViewSet, base_name='collections') subcollections = SubRouterWithFormat() subcollections.register('image', CollectionImageViewSet, base_name='collection-image') apps = SimpleRouter() apps.register(r'preview', PreviewViewSet, base_name='app-preview') apps.register(r'validation', ValidationViewSet, base_name='app-validation') apps.register(r'category', CategoryViewSet, base_name='app-category') apps.register(r'status', StatusViewSet, base_name='app-status') apps.register(r'app', AppViewSet, base_name='app') subapps = SubRouter() subapps.register('refresh-manifest', RefreshManifestViewSet, base_name='app-refresh-manifest') subapps.register('privacy', PrivacyPolicyViewSet, base_name='app-privacy-policy') subapps.register('tags/(?P<tag_text>\w+)', AppTagViewSet, base_name='app-tags')
from django.conf.urls import include, patterns, url from rest_framework.routers import SimpleRouter from mkt.api.base import SubRouterWithFormat from mkt.api.v1.urls import urlpatterns as v1_urls from mkt.api.views import endpoint_removed from mkt.feed.views import (FeedAppImageViewSet, FeedAppViewSet, FeedBrandViewSet, FeedItemViewSet) feed = SimpleRouter() feed.register(r'apps', FeedAppViewSet, base_name='feedapps') feed.register(r'brands', FeedBrandViewSet, base_name='feedbrands') feed.register(r'items', FeedItemViewSet, base_name='feeditems') subfeedapp = SubRouterWithFormat() subfeedapp.register('image', FeedAppImageViewSet, base_name='feed-app-image') urlpatterns = patterns('', url(r'^rocketfuel/collections/.*', endpoint_removed), url(r'^feed/', include(feed.urls)), url(r'^feed/apps/', include(subfeedapp.urls)), ) + v1_urls
from django.conf.urls import include, patterns, url from rest_framework.routers import SimpleRouter from mkt.api.base import SubRouterWithFormat from mkt.api.v1.urls import urlpatterns as v1_urls from mkt.api.views import endpoint_removed from mkt.feed.views import (FeedAppImageViewSet, FeedAppViewSet, FeedBrandViewSet, FeedItemViewSet) feed = SimpleRouter() feed.register(r'apps', FeedAppViewSet, base_name='feedapps') feed.register(r'brands', FeedBrandViewSet, base_name='feedbrands') feed.register(r'items', FeedItemViewSet, base_name='feeditems') subfeedapp = SubRouterWithFormat() subfeedapp.register('image', FeedAppImageViewSet, base_name='feed-app-image') urlpatterns = patterns( '', url(r'^rocketfuel/collections/.*', endpoint_removed), url(r'^feed/', include(feed.urls)), url(r'^feed/apps/', include(subfeedapp.urls)), ) + v1_urls
from django.conf.urls import include, patterns, url from rest_framework.routers import SimpleRouter from mkt.api.base import SubRouterWithFormat from mkt.api.v1.urls import urlpatterns as v1_urls from mkt.api.views import endpoint_removed from mkt.collections.views import CollectionImageViewSet, CollectionViewSet from mkt.feed.views import FeedAppImageViewSet, FeedAppViewSet, FeedItemViewSet feed = SimpleRouter() feed.register(r'apps', FeedAppViewSet, base_name='feedapps') feed.register(r'collections', CollectionViewSet, base_name='collections') feed.register(r'items', FeedItemViewSet, base_name='feeditems') subfeedapp = SubRouterWithFormat() subfeedapp.register('image', FeedAppImageViewSet, base_name='feed-app-image') subcollections = SubRouterWithFormat() subcollections.register('image', CollectionImageViewSet, base_name='collection-image') urlpatterns = patterns('', url(r'^rocketfuel/collections/.*', endpoint_removed), url(r'^feed/', include(feed.urls)), url(r'^feed/apps/', include(subfeedapp.urls)), url(r'^feed/collections/', include(subcollections.urls)), ) + v1_urls
from mkt.langpacks.views import LangPackViewSet from mkt.operators.views import OperatorPermissionViewSet from mkt.recommendations.views import RecommendationView from mkt.search.views import MultiSearchView, NonPublicSearchView, NoRegionSearchView, RocketbarViewV2 from mkt.websites.views import WebsiteSearchView, WebsiteView feed = SimpleRouter() feed.register(r"apps", views.FeedAppViewSet, base_name="feedapps") feed.register(r"brands", views.FeedBrandViewSet, base_name="feedbrands") feed.register(r"collections", views.FeedCollectionViewSet, base_name="feedcollections") feed.register(r"shelves", views.FeedShelfViewSet, base_name="feedshelves") feed.register(r"items", views.FeedItemViewSet, base_name="feeditems") subfeedapp = SubRouterWithFormat() subfeedapp.register("image", views.FeedAppImageViewSet, base_name="feed-app-image") subfeedcollection = SubRouterWithFormat() subfeedcollection.register("image", views.FeedCollectionImageViewSet, base_name="feed-collection-image") subfeedshelf = SubRouterWithFormat() subfeedshelf.register("image", views.FeedShelfImageViewSet, base_name="feed-shelf-image") subfeedshelf.register("image_landing", views.FeedShelfLandingImageViewSet, base_name="feed-shelf-landing-image") langpacks = SimpleRouter() langpacks.register(r"", LangPackViewSet, base_name="langpack") comm_thread = SimpleRouter() comm_thread.register(r"", ThreadViewSetV2, base_name="comm-thread")
from mkt.collections.views import CollectionImageViewSet, CollectionViewSet from mkt.comm.urls import api_patterns as comm_api_patterns from mkt.developers.urls import dev_api_patterns, payments_api_patterns from mkt.features.views import AppFeaturesList from mkt.receipts.urls import receipt_api_patterns from mkt.reviewers.urls import api_patterns as reviewer_api_patterns from mkt.search.api import FeaturedSearchView, RocketbarView, SearchView, SuggestionsView from mkt.stats.urls import stats_api_patterns, txn_api_patterns from mkt.submit.api import PreviewViewSet, StatusViewSet, ValidationViewSet from mkt.webapps.api import AppViewSet, PrivacyPolicyViewSet rocketfuel = SimpleRouter() rocketfuel.register(r"collections", CollectionViewSet, base_name="collections") subcollections = SubRouterWithFormat() subcollections.register("image", CollectionImageViewSet, base_name="collection-image") apps = SimpleRouter() apps.register(r"preview", PreviewViewSet, base_name="app-preview") apps.register(r"validation", ValidationViewSet, base_name="app-validation") apps.register(r"category", CategoryViewSet, base_name="app-category") apps.register(r"status", StatusViewSet, base_name="app-status") apps.register(r"app", AppViewSet, base_name="app") subapps = SubRouter() subapps.register("refresh-manifest", RefreshManifestViewSet, base_name="app-refresh-manifest") subapps.register("privacy", PrivacyPolicyViewSet, base_name="app-privacy-policy") services = SimpleRouter() if settings.ENABLE_API_ERROR_SERVICE: