ci: add dedicated test stage
This commit is contained in:
1 parent
532b4c7710
commit
9022d3b06a
5 files changed
+35
-21
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
stages:
|
stages:
|
||||||
|
- test
|
||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
@@ -11,6 +12,15 @@ variables:
|
|||||||
DOCKER_TLS_CERTDIR: ""
|
DOCKER_TLS_CERTDIR: ""
|
||||||
DOCKER_DRIVER: overlay2
|
DOCKER_DRIVER: overlay2
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
image: python:3.12-slim
|
||||||
|
before_script:
|
||||||
|
- pip install --no-cache-dir -r requirements.txt
|
||||||
|
script:
|
||||||
|
- python -m compileall -q app tests
|
||||||
|
- python -m unittest discover -s tests -q
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
- The job targets GitLab runner tag `fast` and builds through a privileged `docker:29.6.1-dind` service at `DOCKER_HOST=tcp://docker:2375`, with an explicit `alias: docker` and `DOCKER_TLS_CERTDIR=""`.
|
- The job targets GitLab runner tag `fast` and builds through a privileged `docker:29.6.1-dind` service at `DOCKER_HOST=tcp://docker:2375`, with an explicit `alias: docker` and `DOCKER_TLS_CERTDIR=""`.
|
||||||
- The job waits for the DinD daemon and runs `docker info` before starting the build.
|
- The job waits for the DinD daemon and runs `docker info` before starting the build.
|
||||||
- The local image is currently `belki-calculator:test`; the CI target is now `$DOCKER_REGISTRY/belki:latest`.
|
- The local image is currently `belki-calculator:test`; the CI target is now `$DOCKER_REGISTRY/belki:latest`.
|
||||||
- Local validation was performed with `python3 -m unittest discover -s tests -v` (28 tests), `compileall`, JavaScript syntax check, a local browser/API smoke test, and container health/API smoke.
|
- GitLab CI runs `python -m compileall -q app tests` and `python -m unittest discover -s tests -q` in a dedicated `test` stage before build/deploy. Local validation was performed with the same tests, JavaScript syntax check, a local browser/API smoke test, and container health/API smoke.
|
||||||
- The VK dialog layer is covered by tests for step-by-step entry, bulk detection, clarification, confirmation, and cancellation.
|
- The VK dialog layer is covered by tests for step-by-step entry, bulk detection, clarification, confirmation, and cancellation.
|
||||||
- Bulk input accepts a natural one-line format without pipes, e.g. `15.08 11:00 11:20 Дикая Вишня 1604614 Серолап 1617140`; the web form calls `/api/inspect-bulk` and fills recognized fields.
|
- Bulk input accepts a natural one-line format without pipes, e.g. `15.08 11:00 11:20 Дикая Вишня 1604614 Серолап 1617140`; the web form calls `/api/inspect-bulk` and fills recognized fields.
|
||||||
- Training and inspection have the same stepwise/bulk flow. Character identity can be resolved through `/api/resolve-identity` and the persistent SQLite directory; missing pairs produce an explicit prompt instead of guessed data.
|
- Training and inspection have the same stepwise/bulk flow. Character identity can be resolved through `/api/resolve-identity` and the persistent SQLite directory; missing pairs produce an explicit prompt instead of guessed data.
|
||||||
|
|||||||
+6
-8
@@ -47,7 +47,7 @@ class CalculationTests(unittest.TestCase):
|
|||||||
self.assertEqual(result.kitten_points, 12)
|
self.assertEqual(result.kitten_points, 12)
|
||||||
|
|
||||||
def test_non_self_kitten_and_extra_companion(self):
|
def test_non_self_kitten_and_extra_companion(self):
|
||||||
with self.assertRaisesRegex(ValueError, "одинаковый статус"):
|
with self.assertRaisesRegex(ValueError, "Для ЗУ все котята должны быть самостоятельными"):
|
||||||
CoachingSession(
|
CoachingSession(
|
||||||
date="15.08",
|
date="15.08",
|
||||||
skill="ЗУ",
|
skill="ЗУ",
|
||||||
@@ -64,8 +64,8 @@ class CalculationTests(unittest.TestCase):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_non_self_30_minutes_matches_calculator(self):
|
def test_zu_rejects_non_self_kitten(self):
|
||||||
result = calculate_coaching(
|
with self.assertRaisesRegex(ValueError, "Для ЗУ все котята должны быть самостоятельными"):
|
||||||
CoachingSession(
|
CoachingSession(
|
||||||
date="16.08",
|
date="16.08",
|
||||||
skill="ЗУ",
|
skill="ЗУ",
|
||||||
@@ -77,9 +77,6 @@ class CalculationTests(unittest.TestCase):
|
|||||||
kitten_id=134437,
|
kitten_id=134437,
|
||||||
kitten_independence="несамостоятельно",
|
kitten_independence="несамостоятельно",
|
||||||
)
|
)
|
||||||
)
|
|
||||||
self.assertEqual(result.escort_points, 9)
|
|
||||||
self.assertEqual(result.kitten_points, 6)
|
|
||||||
|
|
||||||
def test_non_self_60_minutes_gives_adult_18_and_kitten_12(self):
|
def test_non_self_60_minutes_gives_adult_18_and_kitten_12(self):
|
||||||
result = calculate_coaching(
|
result = calculate_coaching(
|
||||||
@@ -135,9 +132,10 @@ class CalculationTests(unittest.TestCase):
|
|||||||
).escort_points
|
).escort_points
|
||||||
|
|
||||||
self.assertEqual(points("самостоятельно", "самостоятельно"), 18)
|
self.assertEqual(points("самостоятельно", "самостоятельно"), 18)
|
||||||
with self.assertRaisesRegex(ValueError, "одинаковый статус"):
|
with self.assertRaisesRegex(ValueError, "Для ЗУ все котята должны быть самостоятельными"):
|
||||||
points("самостоятельно", "несамостоятельно")
|
points("самостоятельно", "несамостоятельно")
|
||||||
self.assertEqual(points("несамостоятельно", "несамостоятельно"), 30)
|
with self.assertRaisesRegex(ValueError, "Для ЗУ все котята должны быть самостоятельными"):
|
||||||
|
points("несамостоятельно", "несамостоятельно")
|
||||||
|
|
||||||
def test_training_is_fixed(self):
|
def test_training_is_fixed(self):
|
||||||
self.assertEqual(calculate_training(TrainingSession("Белка", 1, "Котёнок", 2)).points, 25)
|
self.assertEqual(calculate_training(TrainingSession("Белка", 1, "Котёнок", 2)).points, 25)
|
||||||
|
|||||||
@@ -26,12 +26,11 @@ class VkBotTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(command["extra_kittens"], (("Второй", 3, "самостоятельно"), ("Третий", 4, "самостоятельно")))
|
self.assertEqual(command["extra_kittens"], (("Второй", 3, "самостоятельно"), ("Третий", 4, "самостоятельно")))
|
||||||
|
|
||||||
def test_parse_one_line_command_with_multiple_kittens_and_shared_status(self):
|
def test_zu_command_rejects_non_self_kittens(self):
|
||||||
command = parse_text_command(
|
with self.assertRaisesRegex(ValueError, "Для ЗУ все котята должны быть самостоятельными"):
|
||||||
"/зу 15.08 11:00 11:20 | Белка [1] | Первый [2], Второй [3] | несам"
|
parse_text_command(
|
||||||
)
|
"/зу 15.08 11:00 11:20 | Белка [1] | Первый [2], Второй [3] | несам"
|
||||||
self.assertEqual(command["kitten_independence"], "несамостоятельно")
|
)
|
||||||
self.assertEqual(command["extra_kittens"], (("Второй", 3, "несамостоятельно"),))
|
|
||||||
|
|
||||||
def test_parse_help(self):
|
def test_parse_help(self):
|
||||||
self.assertEqual(parse_text_command("/help"), {"mode": "help"})
|
self.assertEqual(parse_text_command("/help"), {"mode": "help"})
|
||||||
|
|||||||
@@ -263,19 +263,26 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
dialog.handle(502, answer)
|
dialog.handle(502, answer)
|
||||||
self.assertIn("скриншот", dialog.handle(502, "несам").lower())
|
self.assertIn("скриншот", dialog.handle(502, "несам").lower())
|
||||||
|
|
||||||
def test_compact_command_accepts_all_independence_variants(self):
|
def test_compact_zu_command_rejects_non_self_variants(self):
|
||||||
for value, expected in (
|
for value in (
|
||||||
("сам", "самостоятельно"),
|
("сам", "самостоятельно"),
|
||||||
("самостоятельный", "самостоятельно"),
|
("самостоятельный", "самостоятельно"),
|
||||||
("самостоятельно", "самостоятельно"),
|
("самостоятельно", "самостоятельно"),
|
||||||
|
):
|
||||||
|
parsed = parse_text_command(
|
||||||
|
f"/зу 16.08 10:00 10:10 | Белка [1] | Малыш [2] | {value[0]}"
|
||||||
|
)
|
||||||
|
self.assertEqual(parsed["kitten_independence"], value[1])
|
||||||
|
|
||||||
|
for value in (
|
||||||
("несам", "несамостоятельно"),
|
("несам", "несамостоятельно"),
|
||||||
("несамостоятельный", "несамостоятельно"),
|
("несамостоятельный", "несамостоятельно"),
|
||||||
("несамостоятельно", "несамостоятельно"),
|
("несамостоятельно", "несамостоятельно"),
|
||||||
):
|
):
|
||||||
parsed = parse_text_command(
|
with self.assertRaisesRegex(ValueError, "Для ЗУ все котята должны быть самостоятельными"):
|
||||||
f"/зу 16.08 10:00 10:10 | Белка [1] | Малыш [2] | {value}"
|
parse_text_command(
|
||||||
)
|
f"/зу 16.08 10:00 10:10 | Белка [1] | Малыш [2] | {value[0]}"
|
||||||
self.assertEqual(parsed["kitten_independence"], expected)
|
)
|
||||||
|
|
||||||
def test_keyboard_changes_with_dialog_state(self):
|
def test_keyboard_changes_with_dialog_state(self):
|
||||||
dialog = BelkiDialog()
|
dialog = BelkiDialog()
|
||||||
|
|||||||
Reference in new issue
Block a user