|
| 1 | +import os |
| 2 | +from unittest import mock |
| 3 | + |
| 4 | +import responses # type: ignore |
| 5 | + |
| 6 | +from launchable.utils.http_client import get_base_url |
| 7 | +from tests.cli_test_case import CliTestCase |
| 8 | + |
| 9 | + |
| 10 | +class ModelTest(CliTestCase): |
| 11 | + mock_json = { |
| 12 | + "training_cutoff_test_session_id": 256 |
| 13 | + } |
| 14 | + |
| 15 | + @responses.activate |
| 16 | + @mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token}) |
| 17 | + def test_model(self): |
| 18 | + responses.replace(responses.GET, "{}/intake/organizations/{}/workspaces/{}/model-metadata".format( |
| 19 | + get_base_url(), self.organization, self.workspace), json=self.mock_json, status=200) |
| 20 | + |
| 21 | + result = self.cli('inspect', 'model', mix_stderr=False) |
| 22 | + expect = """| Metadata | Value | |
| 23 | +|---------------------------------|---------| |
| 24 | +| Training Cutoff Test Session ID | 256 | |
| 25 | +""" |
| 26 | + |
| 27 | + self.assertEqual(result.stdout, expect) |
| 28 | + |
| 29 | + @responses.activate |
| 30 | + @mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token}) |
| 31 | + def test_model_json_format(self): |
| 32 | + responses.replace(responses.GET, "{}/intake/organizations/{}/workspaces/{}/model-metadata".format( |
| 33 | + get_base_url(), self.organization, self.workspace), json=self.mock_json, status=200) |
| 34 | + |
| 35 | + result = self.cli('inspect', 'model', "--json", mix_stderr=False) |
| 36 | + |
| 37 | + self.assertEqual(result.stdout, """{ |
| 38 | + "training_cutoff_test_session_id": 256 |
| 39 | +} |
| 40 | +""" |
| 41 | + ) |
0 commit comments