Adding tests for refactored CLI
diff --git a/gpt_engineer/__init__.py b/gpt_engineer/__init__.py
index e69de29bb2..a427f9fc49 100644
--- a/gpt_engineer/__init__.py
+++ b/gpt_engineer/__init__.py
@@ -0,0 +1,8 @@
+# Adding convenience imports to the package
+from gpt_engineer.core import (
+    ai,
+    domain,
+    chat_to_files,
+    steps,
+    db,
+)
diff --git a/gpt_engineer/cli/__init__.py b/gpt_engineer/cli/__init__.py
new file mode 100644
index 0000000000..97b52d8d82
--- /dev/null
+++ b/gpt_engineer/cli/__init__.py
@@ -0,0 +1,15 @@
+"""
+gpt_engineer.cli
+-----------------
+
+The CLI package for the GPT Engineer project, providing the command line interface
+for the application.
+
+Modules:
+    - main: The primary CLI module for GPT Engineer.
+    - collect: Collect send learning data for analysis and improvement.
+    - file_selector: Selecting files using GUI and terminal-based file explorer.
+    - learning: Tools and data structures for data collection.
+
+For more specific details, refer to the docstrings within each module.
+"""
diff --git a/gpt_engineer/core/__init__.py b/gpt_engineer/core/__init__.py
index 370ba51cf7..ddbaaeefef 100644
--- a/gpt_engineer/core/__init__.py
+++ b/gpt_engineer/core/__init__.py
@@ -14,11 +14,3 @@
 
 For more specific details, refer to the docstrings within each module.
 """
-
-from gpt_engineer.core import (
-    ai,
-    domain,
-    chat_to_files,
-    steps,
-    db,
-)
diff --git a/pyproject.toml b/pyproject.toml
index c152645662..9a51f93383 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -65,7 +65,7 @@ gpt-engineer = 'gpt_engineer.cli.main:app'
 ge = 'gpt_engineer.cli.main:app'
 
 [tool.setuptools]
-packages = ["gpt_engineer"]
+packages = ["gpt_engineer", "gpt_engineer.cli", "gpt_engineer.core"]
 
 [tool.ruff]
 select = ["F", "E", "W", "I001"]
diff --git a/tests/test_install.py b/tests/test_install.py
new file mode 100644
index 0000000000..8f0d3bcce5
--- /dev/null
+++ b/tests/test_install.py
@@ -0,0 +1,60 @@
+"""
+Tests for successful import and installation of the package.
+"""
+import subprocess
+import sys
+import venv
+import shutil
+
+# Setup the test environment
+VENV_DIR = "./venv_test_installation"
+venv.create(VENV_DIR, with_pip=True)
+
+
+# Test that the package can be installed via pip
+def test_installation():
+    # Use pip from the virtual environment directly
+    pip_executable = f"{VENV_DIR}/bin/pip"
+    if sys.platform == "win32":
+        pip_executable = f"{VENV_DIR}/Scripts/pip.exe"
+
+    result = subprocess.run([pip_executable, "install", "."], capture_output=True)
+    assert result.returncode == 0, f"Install via pip failed: {result.stderr.decode()}"
+
+
+# Test that the package can be imported
+def test_import():
+    try:
+        from gpt_engineer import (
+            ai,
+            domain,
+            chat_to_files,
+            steps,
+            db,
+        )
+    except ImportError as e:
+        assert False, f"Failed to import {e.name}"
+
+
+# Test that the CLI command works
+def test_cli_execution():
+    # This assumes that after installation, `gpt-engineer` command should work.
+    result = subprocess.run(
+        args=["gpt-engineer", "--help"], capture_output=True, text=True
+    )
+    assert (
+        result.returncode == 0
+    ), f"gpt-engineer command failed with message: {result.stderr}"
+
+
+# Cleanup the test environment
+def test_cleanup():
+    shutil.rmtree(VENV_DIR)
+
+
+# Run the tests using pytest
+if __name__ == "__main__":
+    test_installation()
+    test_import()
+    test_cli_execution()
+    test_cleanup()

Given the bug surfaced and resolved with PR #778, added tests to cover this and related cases in the future.

Created 3 tests (and cleanup utility function) in test_install.py:
* Test that the package can be installed (locally) using `pip`
  * This is done in a virtual environment
  * The virtual environment persists throughout the rest of the tests
* Test that all modules can be imported
  * This tests only the imports of the core modules, as imports of the CLI modules is not recommended or supported (see issue #718)
* Tests that `gpt-engineer` command can be successfully run via the CLI
  * This tests the bug that was resolved in PR #778 and related bugs

After test execution, the virtual environment is removed.

I could use some guidance on how to separate this PR -- which I'm raising from the `refactored-cli-tests` branch which contains only the 3 CLI-related test addition commits -- from the other PR (#778) / branch that I created to solve the bug (branch `bugfix-cli-20231009`).   When I check the git log for the tests branch, I only see the 3 commits I want as part of this PR (which build on the other PR, admittedly).

![image](https://github.com/AntonOsika/gpt-engineer/assets/366332/cc3b3524-610a-4a06-beb6-66856c44d69d)

I hope I've done this right!  Please share any comments or guidance.