|
| 1 | +"""Test top-level imports from the codegen package.""" |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | + |
| 6 | +class TestTopLevelImports: |
| 7 | + """Test that key classes can be imported at the top level of the codegen package.""" |
| 8 | + |
| 9 | + def test_can_import_agent_from_top_level(self): |
| 10 | + """Test that Agent class can be imported from the top level.""" |
| 11 | + # This should work: from codegen import Agent |
| 12 | + from codegen import Agent |
| 13 | + |
| 14 | + # Verify Agent class is available |
| 15 | + assert Agent is not None |
| 16 | + assert callable(Agent) |
| 17 | + |
| 18 | + # Verify it's the same class as importing from the submodule |
| 19 | + from codegen.agents.agent import Agent as DirectAgent |
| 20 | + assert Agent is DirectAgent |
| 21 | + |
| 22 | + def test_agent_in_all_exports(self): |
| 23 | + """Test that Agent is listed in __all__ exports.""" |
| 24 | + import codegen |
| 25 | + |
| 26 | + # Agent should be in the __all__ list |
| 27 | + assert hasattr(codegen, '__all__') |
| 28 | + assert 'Agent' in codegen.__all__ |
| 29 | + |
| 30 | + # Agent should be accessible as an attribute |
| 31 | + assert hasattr(codegen, 'Agent') |
| 32 | + assert codegen.Agent is not None |
| 33 | + |
| 34 | + def test_agent_functionality_works_from_top_level(self): |
| 35 | + """Test that Agent imported from top level is fully functional.""" |
| 36 | + from codegen import Agent |
| 37 | + |
| 38 | + # Test that the class has expected methods |
| 39 | + assert hasattr(Agent, 'run') |
| 40 | + assert hasattr(Agent, 'get_status') |
| 41 | + assert callable(getattr(Agent, 'run')) |
| 42 | + assert callable(getattr(Agent, 'get_status')) |
| 43 | + |
| 44 | + # Test that we can create an Agent instance with None token (it should work) |
| 45 | + agent = Agent(token=None) |
| 46 | + assert agent is not None |
| 47 | + assert hasattr(agent, 'token') |
| 48 | + assert agent.token is None |
| 49 | + |
| 50 | + def test_version_still_available(self): |
| 51 | + """Test that version information is still available alongside Agent.""" |
| 52 | + import codegen |
| 53 | + |
| 54 | + # Version attributes should still be available |
| 55 | + assert hasattr(codegen, '__version__') |
| 56 | + assert hasattr(codegen, 'version') |
| 57 | + assert hasattr(codegen, '__version_tuple__') |
| 58 | + assert hasattr(codegen, 'version_tuple') |
| 59 | + |
| 60 | + # They should be in __all__ |
| 61 | + assert '__version__' in codegen.__all__ |
| 62 | + assert 'version' in codegen.__all__ |
| 63 | + assert '__version_tuple__' in codegen.__all__ |
| 64 | + assert 'version_tuple' in codegen.__all__ |
0 commit comments