Skip to content

Commit

Permalink
Patch mycroft.MycroftSkill with unit tests (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel authored Mar 15, 2023
1 parent 267ee4e commit d4d1cee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions neon_core/skills/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
importlib.reload(mycroft.skills.common_iot_skill)
importlib.reload(mycroft.skills)

import mycroft
mycroft.MycroftSkill = PatchedMycroftSkill
mycroft.FallbackSkill = mycroft.skills.fallback_skill.FallbackSkill

# Manually patch re-defined classes in `mycroft.skills.core`
mycroft.skills.core.MycroftSkill = PatchedMycroftSkill
mycroft.skills.core.FallbackSkill = mycroft.skills.fallback_skill.FallbackSkill
Expand Down
7 changes: 6 additions & 1 deletion test/test_skill_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,23 @@ def test_skill_class_patches(self):
import neon_core.skills # Import to do all the patching
from neon_utils.skills.mycroft_skill import PatchedMycroftSkill
from mycroft.skills import MycroftSkill
from mycroft import MycroftSkill as MycroftSkill1
from mycroft.skills.mycroft_skill import MycroftSkill as MycroftSkill2
from mycroft.skills.core import MycroftSkill as MycroftSkill3
from mycroft.skills.fallback_skill import FallbackSkill
from mycroft import FallbackSkill as FallbackSkill1
from mycroft.skills.core import FallbackSkill as FallbackSkill2
from mycroft.skills.common_play_skill import CommonPlaySkill
from mycroft.skills.common_query_skill import CommonQuerySkill
from mycroft.skills.common_iot_skill import CommonIoTSkill

self.assertEqual(MycroftSkill, PatchedMycroftSkill)
self.assertEqual(MycroftSkill1, PatchedMycroftSkill)
self.assertEqual(MycroftSkill2, PatchedMycroftSkill)
self.assertEqual(MycroftSkill3, PatchedMycroftSkill)
self.assertEqual(FallbackSkill, FallbackSkill2)

self.assertEqual(FallbackSkill1, FallbackSkill)
self.assertEqual(FallbackSkill2, FallbackSkill)

self.assertTrue(issubclass(FallbackSkill, PatchedMycroftSkill))
self.assertTrue(issubclass(CommonPlaySkill, PatchedMycroftSkill))
Expand Down

0 comments on commit d4d1cee

Please sign in to comment.