Skip to content

Commit

Permalink
Merge pull request #819 from PrefectHQ/call-routing-fix-tests
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
zzstoatzz authored Jan 30, 2024
2 parents a2f11eb + 4d14ca4 commit 3356ecf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/examples/call_routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Automatically route customer calls to the right department.

!!! success "💵 Price matching"
```python
department = route_call("Do you price match?")
department = route_call("Well FooCo offered me a better deal")
assert department == Department.SALES
```

Expand Down
24 changes: 11 additions & 13 deletions tests/ai/test_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Literal

import marvin
import pytest

Sentiment = Literal["Positive", "Negative"]

Expand Down Expand Up @@ -83,11 +84,15 @@ async def test_hogwarts_sorting_hat(self):

assert house == "Gryffindor"

async def test_call_routing(self):
from enum import Enum

import marvin

@pytest.mark.parametrize(
"user_input, expected_selection",
[
("I need to update my payment method", "billing"),
("Well FooCo offered me a better deal", "sales"),
("*angry noises*", "support"),
],
)
async def test_call_routing(self, user_input, expected_selection):
class Department(Enum):
SALES = "sales"
SUPPORT = "support"
Expand All @@ -100,11 +105,4 @@ def router(transcript: str) -> Department:
instructions="Select the best department for the customer request",
)

department = router("I need to update my payment method")
assert department == Department.BILLING

department = router("Do you price match?")
assert department == Department.SALES

department = router("*angry noises*")
assert department == Department.SUPPORT
assert router(user_input).value == expected_selection

0 comments on commit 3356ecf

Please sign in to comment.