File size: 1,224 Bytes
2b4bd40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
import os
import unittest
from unittest.mock import patch

from attachment_processing import AttachmentProcessingError, AttachmentProcessor
from model_config import DEFAULT_OLLAMA_MODEL


class AttachmentProcessorConfigurationTests(unittest.TestCase):
    def test_gemma_4_is_the_default_multimodal_model(self) -> None:
        with patch.dict(os.environ, {}, clear=True):
            processor = AttachmentProcessor()
        self.assertEqual(processor.multimodal_model, DEFAULT_OLLAMA_MODEL)
        self.assertEqual(processor.audio_transport, "images")
        self.assertEqual(processor.audio_chunk_seconds, 28)

    def test_rejects_invalid_audio_transport(self) -> None:
        with patch.dict(
            os.environ, {"OLLAMA_AUDIO_TRANSPORT": "unsupported"}, clear=True
        ):
            with self.assertRaises(AttachmentProcessingError):
                AttachmentProcessor()

    def test_rejects_audio_chunks_longer_than_model_limit(self) -> None:
        with patch.dict(
            os.environ, {"GEMMA_AUDIO_CHUNK_SECONDS": "31"}, clear=True
        ):
            with self.assertRaises(AttachmentProcessingError):
                AttachmentProcessor()


if __name__ == "__main__":
    unittest.main()