kopia lustrzana https://github.com/wagtail/wagtail
Rename Admin API endpoint to "main"
rodzic
4e5587918a
commit
33b6d82033
client/tests
wagtail
admin
api/v2/tests
core/tests
tests
|
@ -7,9 +7,9 @@ import 'element-closest';
|
|||
|
||||
global.wagtailConfig = {
|
||||
ADMIN_API: {
|
||||
DOCUMENTS: '/admin/api/v2beta/documents/',
|
||||
IMAGES: '/admin/api/v2beta/images/',
|
||||
PAGES: '/admin/api/v2beta/pages/',
|
||||
DOCUMENTS: '/admin/api/main/documents/',
|
||||
IMAGES: '/admin/api/main/images/',
|
||||
PAGES: '/admin/api/main/pages/',
|
||||
EXTRA_CHILDREN_PARAMETERS: '',
|
||||
},
|
||||
ADMIN_URLS: {
|
||||
|
|
|
@ -12,5 +12,5 @@ for fn in hooks.get_hooks('construct_admin_api'):
|
|||
fn(admin_api)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^v2beta/', admin_api.urls),
|
||||
url(r'^main/', admin_api.urls),
|
||||
]
|
||||
|
|
|
@ -51,7 +51,7 @@ class TestAdminDocumentListing(AdminAPITestCase, TestDocumentListing):
|
|||
self.assertEqual(document['meta']['type'], 'wagtaildocs.Document')
|
||||
|
||||
# Check detail_url
|
||||
self.assertEqual(document['meta']['detail_url'], 'http://localhost/admin/api/v2beta/documents/%d/' % document['id'])
|
||||
self.assertEqual(document['meta']['detail_url'], 'http://localhost/admin/api/main/documents/%d/' % document['id'])
|
||||
|
||||
# Check download_url
|
||||
self.assertTrue(document['meta']['download_url'].startswith('http://localhost/documents/%d/' % document['id']))
|
||||
|
@ -96,7 +96,7 @@ class TestAdminDocumentDetail(AdminAPITestCase, TestDocumentDetail):
|
|||
|
||||
# Check the meta detail_url
|
||||
self.assertIn('detail_url', content['meta'])
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/admin/api/v2beta/documents/1/')
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/admin/api/main/documents/1/')
|
||||
|
||||
# Check the meta download_url
|
||||
self.assertIn('download_url', content['meta'])
|
||||
|
|
|
@ -52,7 +52,7 @@ class TestAdminImageListing(AdminAPITestCase, TestImageListing):
|
|||
self.assertEqual(image['meta']['type'], 'wagtailimages.Image')
|
||||
|
||||
# Check detail url
|
||||
self.assertEqual(image['meta']['detail_url'], 'http://localhost/admin/api/v2beta/images/%d/' % image['id'])
|
||||
self.assertEqual(image['meta']['detail_url'], 'http://localhost/admin/api/main/images/%d/' % image['id'])
|
||||
|
||||
# FIELDS
|
||||
|
||||
|
@ -156,7 +156,7 @@ class TestAdminImageDetail(AdminAPITestCase, TestImageDetail):
|
|||
|
||||
# Check the meta detail_url
|
||||
self.assertIn('detail_url', content['meta'])
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/admin/api/v2beta/images/5/')
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/admin/api/main/images/5/')
|
||||
|
||||
# Check the thumbnail
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ class TestAdminPageListing(AdminAPITestCase, TestPageListing):
|
|||
self.assertIsInstance(feed_image['meta'], dict)
|
||||
self.assertEqual(set(feed_image['meta'].keys()), {'type', 'detail_url', 'download_url'})
|
||||
self.assertEqual(feed_image['meta']['type'], 'wagtailimages.Image')
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/admin/api/v2beta/images/%d/' % feed_image['id'])
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/admin/api/main/images/%d/' % feed_image['id'])
|
||||
|
||||
def test_fields_parent(self):
|
||||
response = self.get_response(type='demosite.BlogEntryPage', fields='parent')
|
||||
|
@ -203,7 +203,7 @@ class TestAdminPageListing(AdminAPITestCase, TestPageListing):
|
|||
'id': 5,
|
||||
'meta': {
|
||||
'type': 'demosite.BlogIndexPage',
|
||||
'detail_url': 'http://localhost/admin/api/v2beta/pages/5/',
|
||||
'detail_url': 'http://localhost/admin/api/main/pages/5/',
|
||||
'html_url': 'http://localhost/blog-index/',
|
||||
},
|
||||
'title': "Blog index"
|
||||
|
@ -217,7 +217,7 @@ class TestAdminPageListing(AdminAPITestCase, TestPageListing):
|
|||
descendants = page['meta']['descendants']
|
||||
self.assertEqual(set(descendants.keys()), {'count', 'listing_url'})
|
||||
self.assertIsInstance(descendants['count'], int)
|
||||
self.assertEqual(descendants['listing_url'], 'http://localhost/admin/api/v2beta/pages/?descendant_of=%d' % page['id'])
|
||||
self.assertEqual(descendants['listing_url'], 'http://localhost/admin/api/main/pages/?descendant_of=%d' % page['id'])
|
||||
|
||||
def test_fields_child_relation(self):
|
||||
response = self.get_response(type='demosite.BlogEntryPage', fields='title,related_links')
|
||||
|
@ -441,7 +441,7 @@ class TestAdminPageDetail(AdminAPITestCase, TestPageDetail):
|
|||
|
||||
# Check the meta detail_url
|
||||
self.assertIn('detail_url', content['meta'])
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/admin/api/v2beta/pages/16/')
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/admin/api/main/pages/16/')
|
||||
|
||||
# Check the meta html_url
|
||||
self.assertIn('html_url', content['meta'])
|
||||
|
@ -461,7 +461,7 @@ class TestAdminPageDetail(AdminAPITestCase, TestPageDetail):
|
|||
self.assertIn('children', content['meta'])
|
||||
self.assertEqual(content['meta']['children'], {
|
||||
'count': 0,
|
||||
'listing_url': 'http://localhost/admin/api/v2beta/pages/?child_of=16'
|
||||
'listing_url': 'http://localhost/admin/api/main/pages/?child_of=16'
|
||||
})
|
||||
|
||||
# Check the parent field
|
||||
|
@ -472,7 +472,7 @@ class TestAdminPageDetail(AdminAPITestCase, TestPageDetail):
|
|||
self.assertIsInstance(content['meta']['parent']['meta'], dict)
|
||||
self.assertEqual(set(content['meta']['parent']['meta'].keys()), {'type', 'detail_url', 'html_url'})
|
||||
self.assertEqual(content['meta']['parent']['meta']['type'], 'demosite.BlogIndexPage')
|
||||
self.assertEqual(content['meta']['parent']['meta']['detail_url'], 'http://localhost/admin/api/v2beta/pages/5/')
|
||||
self.assertEqual(content['meta']['parent']['meta']['detail_url'], 'http://localhost/admin/api/main/pages/5/')
|
||||
self.assertEqual(content['meta']['parent']['meta']['html_url'], 'http://localhost/blog-index/')
|
||||
|
||||
# Check that the custom fields are included
|
||||
|
@ -496,7 +496,7 @@ class TestAdminPageDetail(AdminAPITestCase, TestPageDetail):
|
|||
self.assertIsInstance(content['feed_image']['meta'], dict)
|
||||
self.assertEqual(set(content['feed_image']['meta'].keys()), {'type', 'detail_url', 'download_url'})
|
||||
self.assertEqual(content['feed_image']['meta']['type'], 'wagtailimages.Image')
|
||||
self.assertEqual(content['feed_image']['meta']['detail_url'], 'http://localhost/admin/api/v2beta/images/7/')
|
||||
self.assertEqual(content['feed_image']['meta']['detail_url'], 'http://localhost/admin/api/main/images/7/')
|
||||
|
||||
# Check that the child relations were serialised properly
|
||||
self.assertEqual(content['related_links'], [])
|
||||
|
@ -611,7 +611,7 @@ class TestAdminPageDetail(AdminAPITestCase, TestPageDetail):
|
|||
self.assertIn('children', content['meta'])
|
||||
self.assertEqual(content['meta']['children'], {
|
||||
'count': 5,
|
||||
'listing_url': 'http://localhost/admin/api/v2beta/pages/?child_of=2'
|
||||
'listing_url': 'http://localhost/admin/api/main/pages/?child_of=2'
|
||||
})
|
||||
|
||||
def test_meta_descendants(self):
|
||||
|
@ -622,7 +622,7 @@ class TestAdminPageDetail(AdminAPITestCase, TestPageDetail):
|
|||
self.assertIn('descendants', content['meta'])
|
||||
self.assertEqual(content['meta']['descendants'], {
|
||||
'count': 18,
|
||||
'listing_url': 'http://localhost/admin/api/v2beta/pages/?descendant_of=2'
|
||||
'listing_url': 'http://localhost/admin/api/main/pages/?descendant_of=2'
|
||||
})
|
||||
|
||||
def test_meta_ancestors(self):
|
||||
|
@ -672,7 +672,7 @@ class TestAdminPageDetail(AdminAPITestCase, TestPageDetail):
|
|||
self.assertIsInstance(feed_image['meta'], dict)
|
||||
self.assertEqual(set(feed_image['meta'].keys()), {'type', 'detail_url', 'download_url'})
|
||||
self.assertEqual(feed_image['meta']['type'], 'wagtailimages.Image')
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/admin/api/v2beta/images/%d/' % feed_image['id'])
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/admin/api/main/images/%d/' % feed_image['id'])
|
||||
|
||||
|
||||
class TestAdminPageDetailWithStreamField(AdminAPITestCase):
|
||||
|
|
|
@ -52,7 +52,7 @@ class TestDocumentListing(TestCase):
|
|||
self.assertEqual(document['meta']['type'], 'wagtaildocs.Document')
|
||||
|
||||
# Check detail_url
|
||||
self.assertEqual(document['meta']['detail_url'], 'http://localhost/api/v2beta/documents/%d/' % document['id'])
|
||||
self.assertEqual(document['meta']['detail_url'], 'http://localhost/api/main/documents/%d/' % document['id'])
|
||||
|
||||
# Check download_url
|
||||
self.assertTrue(document['meta']['download_url'].startswith('http://localhost/documents/%d/' % document['id']))
|
||||
|
@ -380,7 +380,7 @@ class TestDocumentDetail(TestCase):
|
|||
|
||||
# Check the meta detail_url
|
||||
self.assertIn('detail_url', content['meta'])
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/api/v2beta/documents/1/')
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/api/main/documents/1/')
|
||||
|
||||
# Check the meta download_url
|
||||
self.assertIn('download_url', content['meta'])
|
||||
|
@ -542,9 +542,9 @@ class TestDocumentCacheInvalidation(TestCase):
|
|||
def test_resave_document_purges(self, purge):
|
||||
get_document_model().objects.get(id=5).save()
|
||||
|
||||
purge.assert_any_call('http://api.example.com/api/v2beta/documents/5/')
|
||||
purge.assert_any_call('http://api.example.com/api/main/documents/5/')
|
||||
|
||||
def test_delete_document_purges(self, purge):
|
||||
get_document_model().objects.get(id=5).delete()
|
||||
|
||||
purge.assert_any_call('http://api.example.com/api/v2beta/documents/5/')
|
||||
purge.assert_any_call('http://api.example.com/api/main/documents/5/')
|
||||
|
|
|
@ -52,7 +52,7 @@ class TestImageListing(TestCase):
|
|||
self.assertEqual(image['meta']['type'], 'wagtailimages.Image')
|
||||
|
||||
# Check detail url
|
||||
self.assertEqual(image['meta']['detail_url'], 'http://localhost/api/v2beta/images/%d/' % image['id'])
|
||||
self.assertEqual(image['meta']['detail_url'], 'http://localhost/api/main/images/%d/' % image['id'])
|
||||
|
||||
# FIELDS
|
||||
|
||||
|
@ -380,7 +380,7 @@ class TestImageDetail(TestCase):
|
|||
|
||||
# Check the meta detail_url
|
||||
self.assertIn('detail_url', content['meta'])
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/api/v2beta/images/5/')
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/api/main/images/5/')
|
||||
|
||||
# Check the title field
|
||||
self.assertIn('title', content)
|
||||
|
@ -537,9 +537,9 @@ class TestImageCacheInvalidation(TestCase):
|
|||
def test_resave_image_purges(self, purge):
|
||||
get_image_model().objects.get(id=5).save()
|
||||
|
||||
purge.assert_any_call('http://api.example.com/api/v2beta/images/5/')
|
||||
purge.assert_any_call('http://api.example.com/api/main/images/5/')
|
||||
|
||||
def test_delete_image_purges(self, purge):
|
||||
get_image_model().objects.get(id=5).delete()
|
||||
|
||||
purge.assert_any_call('http://api.example.com/api/v2beta/images/5/')
|
||||
purge.assert_any_call('http://api.example.com/api/main/images/5/')
|
||||
|
|
|
@ -275,7 +275,7 @@ class TestPageListing(TestCase):
|
|||
self.assertIsInstance(feed_image['meta'], dict)
|
||||
self.assertEqual(set(feed_image['meta'].keys()), {'type', 'detail_url', 'download_url'})
|
||||
self.assertEqual(feed_image['meta']['type'], 'wagtailimages.Image')
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/api/v2beta/images/%d/' % feed_image['id'])
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/api/main/images/%d/' % feed_image['id'])
|
||||
|
||||
def test_fields_tags(self):
|
||||
response = self.get_response(type='demosite.BlogEntryPage', fields='tags')
|
||||
|
@ -819,7 +819,7 @@ class TestPageDetail(TestCase):
|
|||
|
||||
# Check the meta detail_url
|
||||
self.assertIn('detail_url', content['meta'])
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/api/v2beta/pages/16/')
|
||||
self.assertEqual(content['meta']['detail_url'], 'http://localhost/api/main/pages/16/')
|
||||
|
||||
# Check the meta html_url
|
||||
self.assertIn('html_url', content['meta'])
|
||||
|
@ -833,7 +833,7 @@ class TestPageDetail(TestCase):
|
|||
self.assertIsInstance(content['meta']['parent']['meta'], dict)
|
||||
self.assertEqual(set(content['meta']['parent']['meta'].keys()), {'type', 'detail_url', 'html_url'})
|
||||
self.assertEqual(content['meta']['parent']['meta']['type'], 'demosite.BlogIndexPage')
|
||||
self.assertEqual(content['meta']['parent']['meta']['detail_url'], 'http://localhost/api/v2beta/pages/5/')
|
||||
self.assertEqual(content['meta']['parent']['meta']['detail_url'], 'http://localhost/api/main/pages/5/')
|
||||
self.assertEqual(content['meta']['parent']['meta']['html_url'], 'http://localhost/blog-index/')
|
||||
|
||||
# Check that the custom fields are included
|
||||
|
@ -857,7 +857,7 @@ class TestPageDetail(TestCase):
|
|||
self.assertIsInstance(content['feed_image']['meta'], dict)
|
||||
self.assertEqual(set(content['feed_image']['meta'].keys()), {'type', 'detail_url', 'download_url'})
|
||||
self.assertEqual(content['feed_image']['meta']['type'], 'wagtailimages.Image')
|
||||
self.assertEqual(content['feed_image']['meta']['detail_url'], 'http://localhost/api/v2beta/images/7/')
|
||||
self.assertEqual(content['feed_image']['meta']['detail_url'], 'http://localhost/api/main/images/7/')
|
||||
|
||||
# Check that the feed images' thumbnail was serialised properly
|
||||
self.assertEqual(content['feed_image_thumbnail'], {
|
||||
|
@ -1008,7 +1008,7 @@ class TestPageDetail(TestCase):
|
|||
self.assertIsInstance(feed_image['meta'], dict)
|
||||
self.assertEqual(set(feed_image['meta'].keys()), {'type', 'detail_url', 'download_url'})
|
||||
self.assertEqual(feed_image['meta']['type'], 'wagtailimages.Image')
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/api/v2beta/images/%d/' % feed_image['id'])
|
||||
self.assertEqual(feed_image['meta']['detail_url'], 'http://localhost/api/main/images/%d/' % feed_image['id'])
|
||||
|
||||
def test_star_in_wrong_position_gives_error(self):
|
||||
response = self.get_response(16, fields='title,*')
|
||||
|
@ -1198,17 +1198,17 @@ class TestPageCacheInvalidation(TestCase):
|
|||
def test_republish_page_purges(self, purge):
|
||||
Page.objects.get(id=2).save_revision().publish()
|
||||
|
||||
purge.assert_any_call('http://api.example.com/api/v2beta/pages/2/')
|
||||
purge.assert_any_call('http://api.example.com/api/main/pages/2/')
|
||||
|
||||
def test_unpublish_page_purges(self, purge):
|
||||
Page.objects.get(id=2).unpublish()
|
||||
|
||||
purge.assert_any_call('http://api.example.com/api/v2beta/pages/2/')
|
||||
purge.assert_any_call('http://api.example.com/api/main/pages/2/')
|
||||
|
||||
def test_delete_page_purges(self, purge):
|
||||
Page.objects.get(id=16).delete()
|
||||
|
||||
purge.assert_any_call('http://api.example.com/api/v2beta/pages/16/')
|
||||
purge.assert_any_call('http://api.example.com/api/main/pages/16/')
|
||||
|
||||
def test_save_draft_doesnt_purge(self, purge):
|
||||
Page.objects.get(id=2).save_revision()
|
||||
|
|
|
@ -350,7 +350,7 @@ class TestPagePermission(TestCase):
|
|||
client.force_login(event_editor)
|
||||
|
||||
homepage = Page.objects.get(url_path='/home/')
|
||||
explorer_response = client.get('/admin/api/v2beta/pages/?child_of={}&for_explorer=1'.format(homepage.pk))
|
||||
explorer_response = client.get('/admin/api/main/pages/?child_of={}&for_explorer=1'.format(homepage.pk))
|
||||
explorer_json = json.loads(explorer_response.content.decode('utf-8'))
|
||||
|
||||
events_page = Page.objects.get(url_path='/home/events/')
|
||||
|
|
|
@ -27,7 +27,7 @@ urlpatterns = [
|
|||
url(r'^testimages/', include(wagtailimages_test_urls)),
|
||||
url(r'^images/', include(wagtailimages_urls)),
|
||||
|
||||
url(r'^api/v2beta/', api_router.urls),
|
||||
url(r'^api/main/', api_router.urls),
|
||||
url(r'^sitemap\.xml$', sitemaps_views.sitemap),
|
||||
|
||||
url(r'^sitemap-index\.xml$', sitemaps_views.index, {
|
||||
|
|
Ładowanie…
Reference in New Issue