Skip to content

Commit

Permalink
feat: Fix quality tests failures
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Sep 12, 2023
1 parent 76eaea3 commit a694986
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
5 changes: 5 additions & 0 deletions xblock/test/utils/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
from xblock.utils.helpers import child_isinstance


# pylint: disable=unnecessary-pass
class DogXBlock(XBlock):
""" Test XBlock representing any dog. Raises error if instantiated. """
pass


# pylint: disable=unnecessary-pass
class GoldenRetrieverXBlock(DogXBlock):
""" Test XBlock representing a golden retriever """
pass


# pylint: disable=unnecessary-pass
class CatXBlock(XBlock):
""" Test XBlock representing any cat """
pass
Expand All @@ -38,6 +41,7 @@ class TestChildIsInstance(unittest.TestCase):
@XBlock.register_temp_plugin(GoldenRetrieverXBlock, "gr")
@XBlock.register_temp_plugin(CatXBlock, "cat")
@XBlock.register_temp_plugin(BasicXBlock, "block")
# pylint: disable=W0201
def test_child_isinstance(self):
"""
Check that child_isinstance() works on direct children
Expand All @@ -60,6 +64,7 @@ def test_child_isinstance(self):
@XBlock.register_temp_plugin(GoldenRetrieverXBlock, "gr")
@XBlock.register_temp_plugin(CatXBlock, "cat")
@XBlock.register_temp_plugin(BasicXBlock, "block")
# pylint: disable=W0201
def test_child_isinstance_descendants(self):
"""
Check that child_isinstance() works on deeper descendants
Expand Down
6 changes: 6 additions & 0 deletions xblock/test/utils/test_publish_event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Test cases for xblock/utils/publish_event.py
"""
#
# Copyright (C) 2014-2015 edX
#
Expand Down Expand Up @@ -53,6 +56,9 @@ class ObjectUnderTest(XBlockMock, PublishEventMixin):


class TestPublishEventMixin(unittest.TestCase):
"""
Test cases for PublishEventMixin
"""
def assert_no_calls_made(self, block):
self.assertFalse(block.last_call)

Expand Down
8 changes: 6 additions & 2 deletions xblock/test/utils/test_resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Tests for helpers.py
Tests for resources.py
"""

#
Expand Down Expand Up @@ -168,12 +168,16 @@ def __getattr__(self, name):


class TestResourceLoader(unittest.TestCase):
"""
Unit Tests for ResourceLoader
"""

def test_load_unicode(self):
s = ResourceLoader(__name__).load_unicode("data/simple_django_template.txt")
self.assertEqual(s, expected_string)

def test_load_unicode_from_another_module(self):
s = ResourceLoader("xblock.test.utils.unit.data").load_unicode("simple_django_template.txt")
s = ResourceLoader("xblock.test.utils.data").load_unicode("simple_django_template.txt")
self.assertEqual(s, expected_string)

def test_render_django_template(self):
Expand Down
17 changes: 16 additions & 1 deletion xblock/test/utils/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Test cases for xblock/utils/settings.py
"""
import itertools
import unittest
from unittest.mock import Mock, MagicMock, patch
Expand All @@ -10,6 +13,9 @@

@XBlock.wants('settings')
class DummyXBlockWithSettings(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
"""
A dummy XBlock test class provides configurable theme support via Settings Service
"""
block_settings_key = 'dummy_settings_bucket'
default_theme_config = {
'package': 'xblock_utils',
Expand All @@ -19,6 +25,9 @@ class DummyXBlockWithSettings(XBlock, XBlockWithSettingsMixin, ThemableXBlockMix

@XBlock.wants('settings')
class OtherXBlockWithSettings(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
"""
Another XBlock test class provides configurable theme support via Settings Service
"""
block_settings_key = 'other_settings_bucket'
theme_key = 'other_xblock_theme'
default_theme_config = {
Expand All @@ -29,6 +38,9 @@ class OtherXBlockWithSettings(XBlock, XBlockWithSettingsMixin, ThemableXBlockMix

@ddt.ddt
class TestXBlockWithSettingsMixin(unittest.TestCase):
"""
Test cases for XBlockWithSettingsMixin
"""
def setUp(self):
self.settings_service = Mock()
self.runtime = Mock()
Expand All @@ -55,7 +67,10 @@ def test_invokes_get_settings_bucket_and_returns_result(self, block, settings_se


@ddt.ddt
class TextThemableXBlockMixin(unittest.TestCase):
class TestThemableXBlockMixin(unittest.TestCase):
"""
Test cases for ThemableXBlockMixin
"""
def setUp(self):
self.service_mock = Mock()
self.runtime_mock = Mock()
Expand Down
2 changes: 1 addition & 1 deletion xblock/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class XBlockWithSettingsMixin:

def get_xblock_settings(self, default=None):
"""
Gets XBlock-specific settigns for current XBlock
Gets XBlock-specific settings for current XBlock
Returns default if settings service is not available.
Expand Down

0 comments on commit a694986

Please sign in to comment.