import unittest
from src.aiva.config import AIVAConfig
import os

class TestAIVAConfig(unittest.TestCase):

    def setUp(self):
        # Create a temporary config file for testing
        self.config_file = 'test_config.yaml'
        with open(self.config_file, 'w') as f:
            f.write('''
name: TestAIVA
downscale_check_interval: 30
''')

    def tearDown(self):
        # Remove the temporary config file
        os.remove(self.config_file)

    def test_load_config(self):
        config = AIVAConfig(self.config_file)
        self.assertEqual(config.get('name'), 'TestAIVA')
        self.assertEqual(config.downscale_check_interval, 30)

    def test_default_downscale_check_interval(self):
        # Test when downscale_check_interval is not in the config file
        config_file = 'test_config_default.yaml'
        with open(config_file, 'w') as f:
            f.write('''
name: TestAIVA
''')
        config = AIVAConfig(config_file)
        self.assertEqual(config.downscale_check_interval, 60)
        os.remove(config_file)

    def test_config_file_not_found(self):
        config = AIVAConfig('non_existent_config.yaml')
        self.assertEqual(config.get('name'), None)
        self.assertEqual(config.downscale_check_interval, 60)

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