test: refactors blockstore integration tests to run as unit tests.

Tests which @requires_blockstore (i.e. the Blockstore service) have
been made to run as a unit test using the installed Blockstore app, and
will be run by the platform CI.

The Blockstore service tests can still be run manually by setting
EDXAPP_RUN_BLOCKSTORE_TESTS=1

Related fixes:

* adds blockstore bundle storage settings
* let the studio devstack and test servers serve static files from
  the /media URL This allows the blockstore/content libraries API to
  serve blockstore assets in dev.
* Wrap ContentLibrary creation in an atomic transaction, so that if it
 fails, the related bundle can be deleted directly from the database
  during the exception handler. (Previously, we called a REST API which
  deleted it as part of a separate service.)
This commit is contained in:
Jillian Vogel
2022-01-25 21:08:57 +10:30
parent 7d81c3e671
commit 8b77638bf0
13 changed files with 377 additions and 73 deletions

View File

@@ -2,7 +2,7 @@
Helper method to indicate when the blockstore app API is enabled.
"""
from django.conf import settings
from .waffle import BLOCKSTORE_USE_BLOCKSTORE_APP_API
from .waffle import BLOCKSTORE_USE_BLOCKSTORE_APP_API # pylint: disable=invalid-django-waffle-import
def use_blockstore_app():

View File

@@ -8,16 +8,19 @@ import pytest
from django.test import TestCase
from openedx.core.lib import blockstore_api as api
from openedx.core.djangoapps.content_libraries.tests.base import requires_blockstore
from openedx.core.djangoapps.content_libraries.tests.base import (
BlockstoreAppTestMixin,
requires_blockstore,
requires_blockstore_app,
)
# A fake UUID that won't represent any real bundle/draft/collection:
BAD_UUID = UUID('12345678-0000-0000-0000-000000000000')
@requires_blockstore
class BlockstoreApiClientTest(TestCase):
class BlockstoreApiClientTestMixin:
"""
Test for the Blockstore API Client.
Tests for the Blockstore API Client.
The goal of these tests is not to test that Blockstore works correctly, but
that the API client can interact with it and all the API client methods
@@ -192,3 +195,17 @@ class BlockstoreApiClientTest(TestCase):
# Finally, test deleting a link from course's draft:
api.set_draft_link(course_draft.uuid, link2_name, None, None)
assert not api.get_bundle_links(course_bundle.uuid, use_draft=course_draft.name)
@requires_blockstore
class BlockstoreServiceApiClientTest(BlockstoreApiClientTestMixin, TestCase):
"""
Test the Blockstore API Client, using the standalone Blockstore service.
"""
@requires_blockstore_app
class BlockstoreAppApiClientTest(BlockstoreApiClientTestMixin, BlockstoreAppTestMixin, TestCase):
"""
Test the Blockstore API Client, using the installed Blockstore app.
"""