فهرست منبع

fix: update manual realm tool enum and add offline regression check

Ghostuel 2 هفته پیش
والد
کامیت
ab2b0c008d
2فایلهای تغییر یافته به همراه16 افزوده شده و 1 حذف شده
  1. 1 1
      tasks/Component/Costume/costume_test_realm.py
  2. 15 0
      tests/tasks/Component/CostumeRealm/test_realm.py

+ 1 - 1
tasks/Component/Costume/costume_test_realm.py

@@ -62,7 +62,7 @@ if __name__ == '__main__':
     c = Config('oas1')
     c = Config('oas1')
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
-    t.set_costume(RealmType.COSTUME_REALM_2)
+    t.set_costume(RealmType.COSTUME_REALM_YUEHAI_YOUXING)
     t.run()
     t.run()
 
 
 
 

+ 15 - 0
tests/tasks/Component/CostumeRealm/test_realm.py

@@ -22,6 +22,21 @@ class RealmTests(unittest.TestCase):
         self.assertIn('costume_realm_yuehai_youxing',
         self.assertIn('costume_realm_yuehai_youxing',
                       CostumeConfig.model_json_schema()['$defs']['RealmType']['enum'])
                       CostumeConfig.model_json_schema()['$defs']['RealmType']['enum'])
 
 
+    def test_manual_tool_uses_existing_realm_members(self):
+        # Parse only: importing the tool could initialize a real device.
+        import ast
+        from pathlib import Path
+        tool = Path(__file__).resolve().parents[4] / 'tasks/Component/Costume/costume_test_realm.py'
+        tree = ast.parse(tool.read_text(encoding='utf-8'))
+        members = [node.attr for node in ast.walk(tree)
+                   if isinstance(node, ast.Attribute)
+                   and isinstance(node.value, ast.Name)
+                   and node.value.id == 'RealmType']
+        self.assertIn('COSTUME_REALM_YUEHAI_YOUXING', members)
+        for member in members:
+            with self.subTest(member=member):
+                self.assertIn(member, RealmType.__members__)
+
     def test_previous_local_selection_is_preserved(self):
     def test_previous_local_selection_is_preserved(self):
         config = CostumeConfig(costume_realm_type='costume_realm_2')
         config = CostumeConfig(costume_realm_type='costume_realm_2')
         self.assertEqual(config.model_dump(mode='json')['costume_realm_type'],
         self.assertEqual(config.model_dump(mode='json')['costume_realm_type'],