-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat/SkillNetworkRequirements * rename args for clariy * classproperty
- Loading branch information
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import unittest | ||
from ovos_workshop.decorators import classproperty | ||
from ovos_workshop.skills.ovos import OVOSSkill, SkillNetworkRequirements | ||
|
||
|
||
class OfflineSkill(OVOSSkill): | ||
@classproperty | ||
def network_requirements(self): | ||
return SkillNetworkRequirements(internet_before_load=False, | ||
network_before_load=False, | ||
requires_internet=False, | ||
requires_network=False, | ||
no_internet_fallback=True, | ||
no_network_fallback=True) | ||
|
||
|
||
class LANSkill(OVOSSkill): | ||
@classproperty | ||
def network_requirements(self): | ||
scans_on_init = True | ||
return SkillNetworkRequirements(internet_before_load=False, | ||
network_before_load=scans_on_init, | ||
requires_internet=False, | ||
requires_network=True, | ||
no_internet_fallback=True, | ||
no_network_fallback=False) | ||
|
||
|
||
class TestSkill(unittest.TestCase): | ||
|
||
def test_class_property(self): | ||
self.assertEqual(OfflineSkill.network_requirements, | ||
SkillNetworkRequirements(internet_before_load=False, | ||
network_before_load=False, | ||
requires_internet=False, | ||
requires_network=False, | ||
no_internet_fallback=True, | ||
no_network_fallback=True) | ||
) | ||
self.assertEqual(LANSkill.network_requirements, | ||
SkillNetworkRequirements(internet_before_load=False, | ||
network_before_load=True, | ||
requires_internet=False, | ||
requires_network=True, | ||
no_internet_fallback=True, | ||
no_network_fallback=False) | ||
) | ||
self.assertEqual(OVOSSkill.network_requirements, | ||
SkillNetworkRequirements() | ||
) |