|
| 1 | +<?php |
| 2 | +// This file is part of Moodle - http://moodle.org/ |
| 3 | +// |
| 4 | +// Moodle is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU General Public License as published by |
| 6 | +// the Free Software Foundation, either version 3 of the License, or |
| 7 | +// (at your option) any later version. |
| 8 | +// |
| 9 | +// Moodle is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU General Public License for more details. |
| 13 | +// |
| 14 | +// You should have received a copy of the GNU General Public License |
| 15 | +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +namespace aitool_chatgpt; |
| 18 | + |
| 19 | +use local_ai_manager\local\aitool_option_azure; |
| 20 | +use local_ai_manager\local\connector_factory; |
| 21 | + |
| 22 | +/** |
| 23 | + * Tests for ChatGPT connector. |
| 24 | + * |
| 25 | + * @package aitool_chatgpt |
| 26 | + * @copyright 2026 ISB Bayern |
| 27 | + * @author Philipp Memmel |
| 28 | + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 29 | + */ |
| 30 | +final class connector_test extends \advanced_testcase { |
| 31 | + /** |
| 32 | + * Test that the Azure model is only available for supported purposes. |
| 33 | + * |
| 34 | + * @throws \coding_exception |
| 35 | + * @covers \aitool_chatgpt\connector::get_models_by_purpose |
| 36 | + */ |
| 37 | + public function test_get_models_by_purpose_contains_azure_model_only_for_supported_purposes(): void { |
| 38 | + $connectorfactory = \core\di::get(connector_factory::class); |
| 39 | + $connector = $connectorfactory->get_connector_by_connectorname('chatgpt'); |
| 40 | + $modelname = aitool_option_azure::get_azure_model_name('chatgpt'); |
| 41 | + $modelsbypurpose = $connector->get_models_by_purpose(); |
| 42 | + |
| 43 | + foreach (['chat', 'feedback', 'singleprompt', 'translate', 'itt', 'questiongeneration', 'agent'] as $purpose) { |
| 44 | + $this->assertContains($modelname, $modelsbypurpose[$purpose]); |
| 45 | + } |
| 46 | + |
| 47 | + $this->assertNotContains($modelname, $modelsbypurpose['tts']); |
| 48 | + $this->assertNotContains($modelname, $modelsbypurpose['imggen']); |
| 49 | + } |
| 50 | +} |
0 commit comments