File size: 1,231 Bytes
88435ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pytest

from neollm.llm.platform import Platform


class TestPlatform:
    def test_str(self) -> None:
        assert Platform.AZURE == "azure"  # type: ignore
        assert Platform.OPENAI == "openai"  # type: ignore
        assert Platform.ANTHROPIC == "anthropic"  # type: ignore
        assert Platform.GCP == "gcp"  # type: ignore

    def test_init(self) -> None:
        assert Platform("azure") == Platform.AZURE
        assert Platform("openai") == Platform.OPENAI
        assert Platform("anthropic") == Platform.ANTHROPIC
        assert Platform("gcp") == Platform.GCP

        assert Platform("Azure  ") == Platform.AZURE
        assert Platform(" OpenAI") == Platform.OPENAI
        assert Platform("Anthropic ") == Platform.ANTHROPIC
        assert Platform("GcP") == Platform.GCP

    def test_from_string(self) -> None:
        assert Platform.from_string("azure") == Platform.AZURE
        assert Platform.from_string("openai") == Platform.OPENAI
        assert Platform.from_string("anthropic") == Platform.ANTHROPIC
        assert Platform.from_string("gcp") == Platform.GCP

    def test_from_string_error(self) -> None:
        with pytest.raises(ValueError):
            Platform.from_string("error")