Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add integration tests #331

Merged
merged 10 commits into from
Jan 23, 2025
Prev Previous commit
Next Next commit
fix: improve docs and remove try except to allow the fail
  • Loading branch information
MaferMazu committed Dec 27, 2024
commit 14e3e77444abba0020d47a62dadacf881f5098d4
31 changes: 19 additions & 12 deletions integration_tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@


def execute_code(all_code, course_key_str):
"""
Executes the provided code in a sandboxed environment with the specified course context.

Args:
all_code (str): The code to be executed.
course_key_str (str): The string representation of the course key.

Returns:
None
"""
course_key = CourseKey.from_string(course_key_str)
sandbox_service = SandboxService(
course_id=course_key,
Expand All @@ -94,18 +104,15 @@ def execute_code(all_code, course_key_str):
extra_files.append(("python_lib.zip", zip_lib))
python_path.append("python_lib.zip")

try:
safe_exec(
all_code,
globals_dict={},
python_path=python_path,
extra_files=extra_files,
slug="integration-test",
limit_overrides_context=course_key_str,
unsafely=False,
)
except Exception as err:
log.error("Error executing code: %s", err)
safe_exec(
all_code,
globals_dict={},
python_path=python_path,
extra_files=extra_files,
slug="integration-test",
limit_overrides_context=course_key_str,
unsafely=False,
)


if __name__ == "__main__":
Expand Down
Loading