MCPcopy Create free account
hub / github.com/modelscope/modelscope / test_load_index_method

Method test_load_index_method

tests/utils/test_ast.py:139–167  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

137 set())
138
139 def test_load_index_method(self):
140 # test full indexing case
141 output = load_index()
142 self.assertTrue(output[INDEX_KEY] is not None)
143 self.assertTrue(output[REQUIREMENT_KEY] is not None)
144 index, requirements = output[INDEX_KEY], output[REQUIREMENT_KEY]
145 self.assertIsInstance(index, dict)
146 self.assertIsInstance(requirements, dict)
147 self.assertIsInstance(list(index.keys())[0], tuple)
148 index_0 = list(index.keys())[0]
149 self.assertIsInstance(index[index_0], dict)
150 self.assertTrue(index[index_0]['imports'] is not None)
151 self.assertIsInstance(index[index_0]['imports'], list)
152 self.assertTrue(index[index_0]['module'] is not None)
153 self.assertIsInstance(index[index_0]['module'], str)
154 index_0 = list(requirements.keys())[0]
155 self.assertIsInstance(requirements[index_0], list)
156 self.assertIsInstance(output[MD5_KEY], str)
157 self.assertIsInstance(output[MODELSCOPE_PATH_KEY], str)
158 self.assertIsInstance(output[VERSION_KEY], str)
159 self.assertIsInstance(output[FILES_MTIME_KEY], dict)
160
161 # generate ast_template
162 file_path = os.path.join(self.tmp_dir, 'index_file.py')
163 index = generate_ast_template(file_path=file_path, force_rebuild=False)
164 self.assertTrue(os.path.exists(file_path))
165 self.assertEqual(output, index)
166 index_from_prebuilt = load_from_prebuilt(file_path)
167 self.assertEqual(index, index_from_prebuilt)
168
169 def test_update_load_index_method(self):
170 file_number = 20

Callers

nothing calls this directly

Calls 5

load_indexFunction · 0.90
generate_ast_templateFunction · 0.90
load_from_prebuiltFunction · 0.90
keysMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected