Skip to content

Commit

Permalink
fixed mocked openai v1+ chat object response
Browse files Browse the repository at this point in the history
  • Loading branch information
grantbuster committed Jan 4, 2024
1 parent 8fb5a17 commit f06de13
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
TEXT = f.read()


class MockObject(object):
"""Dummy class for mocking api response objects"""
pass


class MockClass:
"""Dummy class to mock various api calls"""

Expand All @@ -38,7 +43,10 @@ def call(*args, **kwargs): # pylint: disable=unused-argument
@staticmethod
def create(*args, **kwargs): # pylint: disable=unused-argument
"""Mock for openai.ChatCompletion.create()"""
response = {'choices': [{'message': {'content': 'hello!'}}]}
response = MockObject()
response.choices = [MockObject()]
response.choices[0].message = MockObject()
response.choices[0].message.content = 'hello!'
return response


Expand Down

0 comments on commit f06de13

Please sign in to comment.