Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djcopley committed Nov 29, 2024
1 parent 2593884 commit 663e1a9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/providers/test_xai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pytest

from shelloracle.providers.xai import XAI


class TestOpenAI:
@pytest.fixture
def xai_config(self, set_config):
config = {
"shelloracle": {"provider": "XAI"},
"provider": {
"XAI": {
"api_key": "xai-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"model": "grok-beta",
}
},
}
set_config(config)

@pytest.fixture
def xai_instance(self, xai_config):
return XAI()

def test_name(self):
assert XAI.name == "XAI"

def test_api_key(self, xai_instance):
assert (
xai_instance.api_key
== "xai-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)

def test_model(self, xai_instance):
assert xai_instance.model == "grok-beta"

@pytest.mark.asyncio
async def test_generate(self, mock_asyncopenai, xai_instance):
result = ""
async for response in xai_instance.generate(""):
result += response
assert result == "head -c 100 /dev/urandom | hexdump -C"

0 comments on commit 663e1a9

Please sign in to comment.