core/domain/exp_domain_test.py
File exp_domain_test.py
has 17203 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
# coding: utf-8
#
# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Function test_validation
has 223 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_validation(self) -> None:
"""Test validation of explorations."""
exploration = exp_domain.Exploration.create_default_exploration('eid')
content_id_generator = translation_domain.ContentIdGenerator(
exploration.next_content_id_index
ExplorationDomainUnitTests
has 54 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class ExplorationDomainUnitTests(test_utils.GenericTestBase):
"""Test the exploration domain object."""
def setUp(self) -> None:
super().setUp()
ExplorationSummaryTests
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class ExplorationSummaryTests(test_utils.GenericTestBase):
def setUp(self) -> None:
super().setUp()
self.signup(self.OWNER_EMAIL, self.OWNER_USERNAME)
ExplorationChangesMergeabilityUnitTests
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class ExplorationChangesMergeabilityUnitTests(
exp_services_test.ExplorationServicesUnitTests,
test_utils.EmailTestBase):
"""Test methods related to exploration changes mergeability."""
Function test_bypassable_state_with_card_is_checkpoint_true_is_invalid
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_bypassable_state_with_card_is_checkpoint_true_is_invalid(
self
) -> None:
# Note: In the graphs below, states with the * symbol are checkpoints.
Function test_all_html_strings_are_collected
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_all_html_strings_are_collected(self) -> None:
exploration = exp_domain.Exploration.create_default_exploration(
'eid', title='title', category='category')
content_id_generator = translation_domain.ContentIdGenerator(
Function test_correct_creation_of_version_diffs
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_correct_creation_of_version_diffs(self) -> None:
# Rename a state.
self.exploration.rename_state('Home', 'Renamed state')
change_list = [exp_domain.ExplorationChange({
'cmd': 'rename_state',
Function test_get_trainable_states_dict
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_get_trainable_states_dict(self) -> None:
"""Test the get_trainable_states_dict() method."""
exp_id = 'exp_id1'
test_exp_filepath = os.path.join(
feconf.TESTS_DATA_DIR, 'string_classifier_test.yaml')
Function test_drag_and_drop_interaction
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_drag_and_drop_interaction(self) -> None:
"""Tests DragAndDrop interaction."""
self.state.recorded_voiceovers.add_content_id_for_voiceover(
'ca_choices_2')
content_id_generator = translation_domain.ContentIdGenerator()
Function test_tag_validation
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_tag_validation(self) -> None:
"""Test validation of exploration tags."""
exploration = exp_domain.Exploration.create_default_exploration('eid')
content_id_generator = translation_domain.ContentIdGenerator(
exploration.next_content_id_index
Function test_text_interaction
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_text_interaction(self) -> None:
"""Tests Text interaction."""
self.state.recorded_voiceovers.add_content_id_for_voiceover(
'feedback_0')
self.state.recorded_voiceovers.add_content_id_for_voiceover(
Function test_fraction_interaction
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_fraction_interaction(self) -> None:
"""Tests Fraction interaction."""
state = self.new_exploration.states['Introduction']
content_id_generator = translation_domain.ContentIdGenerator()
self.set_interaction_for_state(
Function test_item_selection_choice_interaction
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def test_item_selection_choice_interaction(self) -> None:
"""Tests ItemSelection interaction."""
content_id_generator = translation_domain.ContentIdGenerator()
self.set_interaction_for_state(
self.state, 'ItemSelectionInput', content_id_generator)
Function _require_metadata_properties_to_be_synced
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def _require_metadata_properties_to_be_synced(self) -> None:
"""Raises error if there is a new metadata property in the Exploration
object and it is not added in the ExplorationMetadata domain object.
Raises:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"