| 1 | import pytest
|
| 2 |
|
| 3 | from minisweagent.environments import get_environment_class
|
| 4 | from minisweagent.environments.local import LocalEnvironment
|
| 5 |
|
| 6 |
|
| 7 | class TestGetEnvironmentClass:
|
| 8 | def test_get_environment_class_local_full_path(self):
|
| 9 | """Test that get_environment_class returns LocalEnvironment when given full module path."""
|
| 10 | env_class = get_environment_class("minisweagent.environments.local.LocalEnvironment")
|
| 11 | assert env_class is LocalEnvironment
|
| 12 |
|
| 13 | def test_get_environment_class_local_shorthand(self):
|
| 14 | """Test that get_environment_class returns LocalEnvironment when given shorthand."""
|
| 15 | env_class = get_environment_class("local")
|
| 16 | assert env_class is LocalEnvironment
|
| 17 |
|
| 18 | def test_get_environment_class_invalid_spec(self):
|
| 19 | """Test that get_environment_class raises ValueError for invalid spec."""
|
| 20 | with pytest.raises(ValueError, match="Unknown environment type"):
|
| 21 | get_environment_class("invalid_environment")
|
| 22 |
|
| 23 | def test_get_environment_class_invalid_module(self):
|
| 24 | """Test that get_environment_class raises ValueError for non-existent module."""
|
| 25 | with pytest.raises(ValueError, match="Unknown environment type"):
|
| 26 | get_environment_class("nonexistent.module.Class")
|
| 27 |
|