Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
047dc3e6
Unverified
Commit
047dc3e6
authored
1 year ago
by
Siraj R Aizlewood
Browse files
Options
Downloads
Patches
Plain Diff
Add PyTests
parent
c8bccdd7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/test_layer.py
+26
-0
26 additions, 0 deletions
tests/unit/test_layer.py
with
26 additions
and
0 deletions
tests/unit/test_layer.py
+
26
−
0
View file @
047dc3e6
...
@@ -167,6 +167,32 @@ class TestRouteLayer:
...
@@ -167,6 +167,32 @@ class TestRouteLayer:
assert
set
(
route_layer
.
categories
)
==
{
"
Route 1
"
,
"
Route 2
"
}
assert
set
(
route_layer
.
categories
)
==
{
"
Route 1
"
,
"
Route 2
"
}
del
route_layer
del
route_layer
def
test_list_route_names
(
self
,
openai_encoder
,
routes
):
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
)
route_names
=
route_layer
.
list_route_names
()
assert
set
(
route_names
)
==
{
route
.
name
for
route
in
routes
},
"
The list of route names should match the names of the routes added.
"
def
test_remove_route
(
self
,
openai_encoder
,
routes
):
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
)
# Remove a route by name
route_to_remove
=
routes
[
0
].
name
route_layer
.
remove
(
route_to_remove
)
# Ensure the route is no longer in the route layer
assert
route_to_remove
not
in
route_layer
.
list_route_names
(),
"
The route should be removed from the route layer.
"
# Ensure the route is no longer in the index or categories
assert
route_to_remove
not
in
route_layer
.
categories
,
"
The route should be removed from the categories.
"
# Ensure the route's utterances are no longer in the index
for
utterance
in
routes
[
0
].
utterances
:
assert
utterance
not
in
route_layer
.
index
,
"
The route
'
s utterances should be removed from the index.
"
def
test_remove_route_not_found
(
self
,
openai_encoder
,
routes
):
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
)
# Attempt to remove a route that does not exist
non_existent_route
=
"
non-existent-route
"
with
pytest
.
raises
(
ValueError
)
as
excinfo
:
route_layer
.
remove
(
non_existent_route
)
assert
str
(
excinfo
.
value
)
==
f
"
Route `
{
non_existent_route
}
` not found
"
,
"
Attempting to remove a non-existent route should raise a ValueError.
"
def
test_add_multiple_routes
(
self
,
openai_encoder
,
routes
):
def
test_add_multiple_routes
(
self
,
openai_encoder
,
routes
):
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
)
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
)
route_layer
.
_add_routes
(
routes
=
routes
)
route_layer
.
_add_routes
(
routes
=
routes
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment