Testing with PyTest and LangChain

This lesson preview is part of the Responsive LLM Applications with Server-Sent Events course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Responsive LLM Applications with Server-Sent Events, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Responsive LLM Applications with Server-Sent Events
  • [00:00 - 00:07] In this lesson we will learn how to test our right point. We will use PyTest which is a widely used Python library to set up tests.

    [00:08 - 00:21] We will test the handler as often directly testing the right point could be call troublesome due to middleware such as autotification, middleware, carpenterware and so on. And lastly we will use the fake relm long-shan class.

    [00:22 - 00:31] It's a very useful class, especially for testing purposes. If you're not not satisfied with the implementation of function you can use the custom MacPher.

    [00:32 - 00:38] Let's look at our test. We are using the PyTest decorator. Then we create our root function.

    [00:39 - 00:49] We create our chat and then we test the function. We pass a few message. We append the event as they are created.

    [00:50 - 00:55] At the end we check that every event has been correctly emitted. We have tested our endpoint.

    [00:56 - 01:00] And that's it for our backhand, in the next module we will build a chat.