aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/test_basic.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-06-29 22:35:29 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-06-29 22:35:29 +0200
commit8c5c0138d71023079e9f0ac45f2f01a7e96784bc (patch)
treed15c4579c00fcb7d1f73a0d8f627b5ab398efbd1 /test/py/test_basic.py
parentlog: minor refactoring (diff)
downloadcimple-8c5c0138d71023079e9f0ac45f2f01a7e96784bc.tar.gz
cimple-8c5c0138d71023079e9f0ac45f2f01a7e96784bc.zip
test: shuffle files a bit
This should hopefully reduce clutter in the test/ directory. Side note: if I leave the __init__.py file in the new py/ directory, pytest fails with import errors. To make it work, I need to either delete it or keep the __init__.py file in both test/ and py/. No idea why.
Diffstat (limited to 'test/py/test_basic.py')
-rw-r--r--test/py/test_basic.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/py/test_basic.py b/test/py/test_basic.py
new file mode 100644
index 0000000..e8a00e1
--- /dev/null
+++ b/test/py/test_basic.py
@@ -0,0 +1,50 @@
+# Copyright (c) 2023 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "cimple" project.
+# For details, see https://github.com/egor-tensin/cimple.
+# Distributed under the MIT License.
+
+import pytest
+
+from lib.process import LoggingEvent
+
+
+def test_server_and_workers_run(server_and_workers):
+ pass
+
+
+def test_client_version(client, version):
+ output = client.run('--version')
+ assert output.endswith(version + '\n')
+
+
+class LoggingEventRunComplete(LoggingEvent):
+ def __init__(self, target):
+ self.counter = 0
+ self.target = target
+ super().__init__(timeout=60)
+
+ def log_line_matches(self, line):
+ return 'Received a "run complete" message from worker' in line
+
+ def set(self):
+ self.counter += 1
+ if self.counter == self.target:
+ super().set()
+
+
+def _test_repo_internal(server_and_workers, test_repo, client, numof_runs):
+ server, workers = server_and_workers
+ event = LoggingEventRunComplete(numof_runs)
+ server.logger.add_event(event)
+ for i in range(numof_runs):
+ client.run('run', test_repo.path, 'HEAD')
+ event.wait()
+ assert numof_runs == test_repo.count_ci_output_files()
+
+
+def test_repo(server_and_workers, test_repo, client):
+ _test_repo_internal(server_and_workers, test_repo, client, 1)
+
+
+def test_repo_10(server_and_workers, test_repo, client):
+ _test_repo_internal(server_and_workers, test_repo, client, 10)