Skip to content

Commit

Permalink
unittests: update tests (#421)
Browse files Browse the repository at this point in the history
* minimize pipelines in othr tests

minimize pipelines in othr tests

minimize pipelines in othr tests

logging

unitests

update tests to use explicit pipelines

* debug failures

* debug failures

* add alerts skill license exceptions

* debug failures
  • Loading branch information
JarbasAl authored Feb 25, 2024
1 parent f643dfb commit fd43226
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/license_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
requirements: 'requirements-all.txt'
fail: 'Copyleft,Other,Error'
fails-only: true
exclude: '^(precise-runner|fann2|tqdm|bs4|sonopy|ovos-stt-plugin).*'
exclude: '^(precise-runner|fann2|tqdm|bs4|sonopy|caldav|recurring-ical-events|x-wr-timezone).*'
exclude-license: '^(Mozilla).*$'
- name: Print report
if: ${{ always() }}
Expand Down
3 changes: 2 additions & 1 deletion test/end2end/routing/test_sched.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ def test_no_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.pipeline = ["adapt_high"]

messages = []

def new_msg(msg):
nonlocal messages
m = Message.deserialize(msg)
if m.msg_type in ["ovos.skills.settings_changed"]:
if m.msg_type in ["ovos.skills.settings_changed", "ovos.common_play.status"]:
return # skip these, only happen in 1st run
messages.append(m)
print(len(messages), m.msg_type, m.context.get("source"), m.context.get("destination"))
Expand Down
7 changes: 3 additions & 4 deletions test/end2end/routing/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ def test_no_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.pipeline = ["adapt_high"]

messages = []

def new_msg(msg):
nonlocal messages
m = Message.deserialize(msg)
if m.msg_type in ["ovos.skills.settings_changed"]:
return # skip these, only happen in 1st run
if m.msg_type in ["ovos.skills.settings_changed", "ovos.common_play.status"]:
return # skip these
messages.append(m)
print(len(messages), m.msg_type, m.context.get("source"), m.context.get("destination"))

Expand Down Expand Up @@ -81,5 +82,3 @@ def wait_for_n_messages(n):
for m in messages[3:]:
self.assertEqual(m.context["source"], "B")
self.assertEqual(m.context["destination"], "A")


28 changes: 28 additions & 0 deletions test/end2end/session/test_complete_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ def test_complete_failure(self):
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.active_skills = [(self.skill_id, time.time())]
SessionManager.default_session.pipeline = [
"stop_high",
"converse",
"padatious_high",
"adapt_high",
"fallback_high",
"stop_medium",
"adapt_medium",
"padatious_medium",
"adapt_low",
"common_qa",
"fallback_medium",
"fallback_low"
]
messages = []

def new_msg(msg):
Expand Down Expand Up @@ -136,6 +150,20 @@ def test_complete_failure_lang_detect(self):
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.active_skills = [(self.skill_id, time.time())]
SessionManager.default_session.pipeline = [
"stop_high",
"converse",
"padatious_high",
"adapt_high",
"fallback_high",
"stop_medium",
"adapt_medium",
"padatious_medium",
"adapt_low",
"common_qa",
"fallback_medium",
"fallback_low"
]

stt_lang_detect = "pt-pt"

Expand Down
5 changes: 5 additions & 0 deletions test/end2end/session/test_converse.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def test_no_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"padatious_high",
"adapt_high"
]

messages = []

Expand Down
17 changes: 16 additions & 1 deletion test/end2end/session/test_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def test_fallback(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"fallback_high",
"fallback_medium",
"fallback_low"
]
messages = []

def new_msg(msg):
Expand Down Expand Up @@ -128,9 +134,18 @@ def test_fallback_with_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"fallback_high",
"fallback_medium",
"fallback_low"
]
messages = []

sess = Session()
sess = Session(pipeline=[
"fallback_high",
"fallback_medium",
"fallback_low"
])

def new_msg(msg):
nonlocal messages
Expand Down
6 changes: 6 additions & 0 deletions test/end2end/session/test_fallback_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def test_fallback_v1(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"fallback_high",
"fallback_medium",
"fallback_low"
]
messages = []

def new_msg(msg):
Expand Down
24 changes: 24 additions & 0 deletions test/end2end/session/test_get_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def test_no_response(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"padatious_high",
"adapt_high"
]

messages = []

Expand Down Expand Up @@ -160,6 +165,11 @@ def test_with_response(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"padatious_high",
"adapt_high"
]

messages = []

Expand Down Expand Up @@ -326,6 +336,10 @@ def test_cancel_response(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"padatious_high",
"adapt_high"]

messages = []

Expand Down Expand Up @@ -492,6 +506,11 @@ def test_with_reprompt(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"padatious_high",
"adapt_high"
]

messages = []

Expand Down Expand Up @@ -647,6 +666,11 @@ def test_nested(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"padatious_high",
"adapt_high"
]

messages = []

Expand Down
10 changes: 9 additions & 1 deletion test/end2end/session/test_sched.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def test_no_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"adapt_high"
]

messages = []

Expand Down Expand Up @@ -127,6 +130,9 @@ def test_explicit_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"adapt_high"
]

messages = []

Expand All @@ -148,7 +154,9 @@ def wait_for_n_messages(n):

self.core.bus.on("message", new_msg)

sess = Session()
sess = Session(pipeline=[
"adapt_high"
])
utt = Message("recognizer_loop:utterance",
{"utterances": ["schedule event"]},
{"session": sess.serialize()})
Expand Down
18 changes: 17 additions & 1 deletion test/end2end/session/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ovos_bus_client.message import Message
from ovos_bus_client.session import SessionManager, Session

from ..minicroft import get_minicroft


Expand All @@ -20,6 +21,9 @@ def test_no_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"adapt_high"
]

messages = []

Expand Down Expand Up @@ -113,6 +117,10 @@ def test_explicit_default_session(self):
SessionManager.default_session.lang = "en-us"
now = time.time()
SessionManager.default_session.active_skills = [(self.skill_id, now)]
SessionManager.default_session.pipeline = [
"converse",
"adapt_high"
]

messages = []

Expand Down Expand Up @@ -216,6 +224,10 @@ def test_explicit_session(self):
SessionManager.sessions = {}
SessionManager.default_session = SessionManager.sessions["default"] = Session("default")
SessionManager.default_session.lang = "en-us"
SessionManager.default_session.pipeline = [
"converse",
"adapt_high"
]

messages = []

Expand All @@ -237,7 +249,11 @@ def wait_for_n_messages(n):

self.core.bus.on("message", new_msg)

sess = Session("test-session")
sess = Session("test-session",
pipeline=[
"converse",
"adapt_high"
])
now = time.time()
sess.active_skills = [(self.skill_id, now)]
utt = Message("recognizer_loop:utterance",
Expand Down
Loading

0 comments on commit fd43226

Please sign in to comment.