-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d05e557
commit 41f8f0c
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
from griptape.artifacts import AudioArtifact, BaseArtifact | ||
|
||
|
||
class TestAudioArtifact: | ||
@pytest.fixture | ||
def audio_artifact(self): | ||
return AudioArtifact(value=b"some binary audio data", format="pcm", model="provider/model", prompt="two words") | ||
|
||
def test_mime_type(self, audio_artifact: AudioArtifact): | ||
assert audio_artifact.mime_type == "audio/pcm" | ||
|
||
def test_to_text(self, audio_artifact: AudioArtifact): | ||
assert audio_artifact.to_text() == "Media, type: audio/pcm, size: 22 bytes" | ||
|
||
def test_to_dict(self, audio_artifact: AudioArtifact): | ||
audio_dict = audio_artifact.to_dict() | ||
|
||
assert audio_dict["format"] == "pcm" | ||
assert audio_dict["model"] == "provider/model" | ||
assert audio_dict["prompt"] == "two words" | ||
assert audio_dict["value"] == "c29tZSBiaW5hcnkgYXVkaW8gZGF0YQ==" | ||
|
||
def test_deserialization(self, audio_artifact): | ||
artifact_dict = audio_artifact.to_dict() | ||
deserialized_artifact = BaseArtifact.from_dict(artifact_dict) | ||
|
||
assert isinstance(deserialized_artifact, AudioArtifact) | ||
|
||
assert deserialized_artifact.value == b"some binary audio data" | ||
assert deserialized_artifact.mime_type == "audio/pcm" | ||
assert deserialized_artifact.format == "pcm" | ||
assert deserialized_artifact.model == "provider/model" | ||
assert deserialized_artifact.prompt == "two words" |