diff --git a/tests/commands/export/test_integration.py b/tests/commands/export/test_integration.py index a7a73647..561cbb1b 100644 --- a/tests/commands/export/test_integration.py +++ b/tests/commands/export/test_integration.py @@ -212,3 +212,30 @@ def test_no_ocen(create_package): with tarfile.open(f'{task_id}.tgz', "r") as tar: sinol_util.extract_tar(tar, tmpdir) assert not os.path.exists(os.path.join(tmpdir, task_id, "attachments", f"{task_id}ocen.zip")) + + +@pytest.mark.parametrize("create_package", [util.get_dlazaw_package()], indirect=True) +def test_no_ocen_and_dlazaw(create_package): + """ + Test if ocen archive is not created when there are no ocen tests. + Also test if dlazaw archive is created. + """ + parser = configure_parsers() + args = parser.parse_args(["export", "--no-statement"]) + command = Command() + command.run(args) + task_id = package_util.get_task_id() + + with tempfile.TemporaryDirectory() as tmpdir: + with tarfile.open(f'{task_id}.tgz', "r") as tar: + sinol_util.extract_tar(tar, tmpdir) + + assert not os.path.exists(os.path.join(tmpdir, task_id, "attachments", f"{task_id}ocen.zip")) + dlazaw_archive = os.path.join(tmpdir, task_id, "attachments", f"dlazaw.zip") + assert os.path.exists(dlazaw_archive) + + with zipfile.ZipFile(dlazaw_archive, "r") as zip: + zip.extractall(os.path.join(tmpdir)) + + assert os.path.exists(os.path.join(tmpdir, "dlazaw")) + assert os.path.exists(os.path.join(tmpdir, "dlazaw", "epic_file")) diff --git a/tests/packages/dlazaw/config.yml b/tests/packages/dlazaw/config.yml new file mode 100644 index 00000000..8caed113 --- /dev/null +++ b/tests/packages/dlazaw/config.yml @@ -0,0 +1,5 @@ +title: Package with no ocen files and dlazaw dir +sinol_task_id: dla +sinol_contest_type: oi +time_limit: 1000 +memory_limit: 10240 diff --git a/tests/packages/dlazaw/dlazaw/epic_file b/tests/packages/dlazaw/dlazaw/epic_file new file mode 100644 index 00000000..f81fce04 --- /dev/null +++ b/tests/packages/dlazaw/dlazaw/epic_file @@ -0,0 +1 @@ +this is a file diff --git a/tests/packages/dlazaw/in/.gitkeep b/tests/packages/dlazaw/in/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/packages/dlazaw/out/.gitkeep b/tests/packages/dlazaw/out/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/packages/dlazaw/prog/dla.cpp b/tests/packages/dlazaw/prog/dla.cpp new file mode 100644 index 00000000..9d30bab0 --- /dev/null +++ b/tests/packages/dlazaw/prog/dla.cpp @@ -0,0 +1,9 @@ +#include + +using namespace std; + +int main() { + int a, b; + cin >> a >> b; + cout << a + b; +} diff --git a/tests/packages/dlazaw/prog/dlaingen.cpp b/tests/packages/dlazaw/prog/dlaingen.cpp new file mode 100644 index 00000000..7c84e777 --- /dev/null +++ b/tests/packages/dlazaw/prog/dlaingen.cpp @@ -0,0 +1,9 @@ +#include + +using namespace std; + +int main() { + ofstream f("ocen1a.in"); + f << "1 1\n"; + f.close(); +} diff --git a/tests/util.py b/tests/util.py index c29d99c3..df236d11 100644 --- a/tests/util.py +++ b/tests/util.py @@ -164,6 +164,13 @@ def get_bad_tests_package_path(): return os.path.join(os.path.dirname(__file__), "packages", "bad_tests") +def get_dlazaw_package(): + """ + Get path to package with dlazaw dir and no ocen tests (/tests/packages/dlazaw) + """ + return os.path.join(os.path.dirname(__file__), "packages", "dlazaw") + + def create_ins(package_path, task_id): """ Create .in files for package.