/
githubmirror
/
oppia
Обзор
Документация
Войти
/
githubmirror
/
oppia
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
core/domain/calculation_registry_test.py
65 строк
2 KB
Gabriel Fuentes
Black formatter staging (#23456)
05 окт 2025, 06:15
Не верифицирован
05 окт 2025, 06:15
62ec95a
Код
Авторство
О чём код?
# coding: utf-8 # # Copyright 2018 The Oppia Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tests for calculation registry.""" from __future__ import annotations from core.domain import calculation_registry from core.tests import test_utils from extensions.answer_summarizers import models class CalculationRegistryTests(test_utils.GenericTestBase): """Provides testing of the calculation registry.""" def test_get_calculation_by_id(self) -> None: self.assertTrue( isinstance( calculation_registry.Registry.get_calculation_by_id( 'AnswerFrequencies' ), models.AnswerFrequencies, ) ) with self.assertRaisesRegex( TypeError, '\'a\' is not a valid calculation id.' ): calculation_registry.Registry.get_calculation_by_id('a') def test_get_calculation_by_id_when_calculations_dict_have_calculation_id( self, ) -> None: # Top5AnswerFrequencies is not present in calculations_dict, # So Top5AnswerFrequencies will be inserted into calculations_dict. self.assertTrue( isinstance( calculation_registry.Registry.get_calculation_by_id( 'Top5AnswerFrequencies' ), models.Top5AnswerFrequencies, ) ) # Top5AnswerFrequencies is present in calculations_dict # So Top5AnswerFrequencies will not be inserted again. self.assertTrue( isinstance( calculation_registry.Registry.get_calculation_by_id( 'Top5AnswerFrequencies' ), models.Top5AnswerFrequencies, ) )