Added coverage testing
This commit is contained in:
parent
4268b66b27
commit
6e1b26440f
5
Makefile
5
Makefile
@ -1,6 +1,11 @@
|
||||
PYTHON=env/bin/python
|
||||
DROPZONE=5.7.0
|
||||
|
||||
test:
|
||||
coverage run --include "app/*" --omit "*/migrations/*" app/manage.py test app
|
||||
coverage html
|
||||
coverage report
|
||||
|
||||
dev-setup:
|
||||
env/bin/pip install -r requirements.txt
|
||||
env/bin/pip install -r dev-requirements.txt
|
||||
|
||||
@ -44,6 +44,10 @@ class LibraryTestCase(AccessTestCase):
|
||||
'/collections/2/works/1/upload',
|
||||
'/collections/2/docs/1/annotate',
|
||||
|
||||
# Need to add storage before we can test these
|
||||
#'/api/collections/2',
|
||||
#'/api/collections/2/works/1',
|
||||
|
||||
'/admin/library/collection/',
|
||||
'/admin/library/document/',
|
||||
'/admin/library/ensembleaccess/',
|
||||
@ -81,28 +85,9 @@ class LibraryTestCase(AccessTestCase):
|
||||
|
||||
|
||||
|
||||
def oldSetUp(self):
|
||||
self.homer = User.objects.create(username='homer')
|
||||
self.ned = User.objects.create(username="ned")
|
||||
self.lisa = User.objects.create(username="lisa")
|
||||
self.dewey = User.objects.create(username="dewey")
|
||||
|
||||
self.be_sharps = self.homer.ensembles.create(name='Be Sharps', code="barbershop")
|
||||
self.sesd = self.dewey.ensembles.create(name="Springfield Elementary School Band", code="sax")
|
||||
|
||||
self.sel = self.lisa.collections.create(name="Springfield Elementary Library")
|
||||
self.flanders = self.ned.collections.create(name="Neds Shed")
|
||||
|
||||
def test_integration(self):
|
||||
pass
|
||||
|
||||
# def test_get_views(self):
|
||||
#
|
||||
# self.assertAccess({ x: False for x in self.PROTECTED_URLS })
|
||||
#
|
||||
# self.login('admin', 'secret')
|
||||
# self.assertAccess({ x: True for x in self.PROTECTED_URLS })
|
||||
|
||||
def test_superuser_access(self):
|
||||
self.login('admin', 'secret')
|
||||
self.assertAccess({
|
||||
|
||||
@ -35,7 +35,7 @@ urlpatterns = [
|
||||
path('collections/<int:collection>/download/<int:section>/<str:filename>', views.PartDownloadView.as_view(), name="part_download"),
|
||||
|
||||
#path('api/', include(router.urls))
|
||||
path('api/collections/<int:collection>', api.CollectionExportView.as_view(), name="collection_export"),
|
||||
path('api/collections/<int:pk>', api.CollectionExportView.as_view(), name="collection_export"),
|
||||
path('api/collections/<int:collection>/works/<int:pk>', api.WorkExportView.as_view(), name="work_export"),
|
||||
path('api/collections/<int:collection>/import', api.WorkImportView.as_view(), name="work_import"),
|
||||
path('api/collections/<int:collection>/bulk_import', api.CollectionImportView.as_view(), name="collection_import"),
|
||||
|
||||
@ -167,16 +167,20 @@ from rest_framework import generics
|
||||
|
||||
class CollectionExportView(AuthorizedResourceMixin, generics.RetrieveAPIView):
|
||||
serializer_class = CollectionSerializer
|
||||
lookup_url_kwarg = 'collection'
|
||||
|
||||
def get_queryset(self):
|
||||
if self.request.user.is_superuser:
|
||||
return Collection.objects.all()
|
||||
return Collection.objects.filter(administrators=self.request.user)
|
||||
|
||||
class WorkExportView(AuthorizedResourceMixin, generics.RetrieveAPIView):
|
||||
serializer_class = WorkSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
return Work.objects.filter(collection__administrators=self.request.user, collection=self.kwargs['collection'])
|
||||
works = Work.objects.filter(collection=self.kwargs['collection'])
|
||||
if self.request.user.is_superuser:
|
||||
return works
|
||||
return works.filter(collection__administrators=self.request.user)
|
||||
|
||||
class WorkImportView(AuthorizedResourceMixin, generics.CreateAPIView):
|
||||
serializer_class = WorkSerializer
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user