nilshoehing commited on
Commit
180f0c3
·
verified ·
1 Parent(s): 350c17c

Add pattern parser regression test

Browse files
Files changed (1) hide show
  1. tests/test_verification.py +31 -1
tests/test_verification.py CHANGED
@@ -1,11 +1,19 @@
1
  from __future__ import annotations
2
 
3
  import subprocess
 
4
  import unittest
 
5
  from unittest.mock import patch
6
 
7
  from space_app.verification import VerificationService
8
 
 
 
 
 
 
 
9
 
10
  class VerificationTests(unittest.TestCase):
11
  def test_flow_free_example_if_solver_available(self) -> None:
@@ -44,6 +52,28 @@ class VerificationTests(unittest.TestCase):
44
  problem_ascii=board,
45
  board_ascii=board,
46
  args="4x4de",
47
- )
48
  self.assertFalse(result["correct"])
49
  self.assertEqual(result.get("error"), "Undead verification timed out.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from __future__ import annotations
2
 
3
  import subprocess
4
+ import sys
5
  import unittest
6
+ from pathlib import Path
7
  from unittest.mock import patch
8
 
9
  from space_app.verification import VerificationService
10
 
11
+ RLP_PATH = Path(__file__).resolve().parents[1] / "submodules" / "rlp"
12
+ if str(RLP_PATH) not in sys.path:
13
+ sys.path.insert(0, str(RLP_PATH))
14
+
15
+ from rlp.ascii_parser import parse_ascii_pattern # type: ignore
16
+
17
 
18
  class VerificationTests(unittest.TestCase):
19
  def test_flow_free_example_if_solver_available(self) -> None:
 
52
  problem_ascii=board,
53
  board_ascii=board,
54
  args="4x4de",
55
+ )
56
  self.assertFalse(result["correct"])
57
  self.assertEqual(result.get("error"), "Undead verification timed out.")
58
+
59
+ def test_pattern_parser_keeps_single_digit_top_clue_rows(self) -> None:
60
+ board = "\n".join(
61
+ [
62
+ " 1 ",
63
+ " 1 2 3 3 3 ",
64
+ " +--+--+--+--+--+",
65
+ "2 1|##|##|..|##|..|",
66
+ " +--+--+--+--+--+",
67
+ " 1|..|##|..|..|..|",
68
+ " +--+--+--+--+--+",
69
+ " 3|..|..|##|##|##|",
70
+ " +--+--+--+--+--+",
71
+ " 3|..|..|##|##|##|",
72
+ " +--+--+--+--+--+",
73
+ " 3|..|..|##|##|##|",
74
+ " +--+--+--+--+--+",
75
+ ]
76
+ )
77
+ state = parse_ascii_pattern(board)
78
+ self.assertEqual(state["common"]["rowlen"][:5], [1, 1, 1, 2, 1])
79
+ self.assertEqual(state["common"]["rowdata"][:6], [1, 2, 3, 1, 3, 3])