4848# Map that projects Schema.GetErrorsFor(doc) into an Errors field (LINQ syntax)
4949_MAP_VALIDATE_DOCUMENT = (
5050 "from doc in docs "
51- " where MetadataFor(doc)[\ " @collection\ " ] != \ " @hilo\" "
51+ ' where MetadataFor(doc)["@collection"] != "@hilo" '
5252 "select new { Id = doc.Id, Errors = Schema.GetErrorsFor(doc) }"
5353)
5454
@@ -75,9 +75,7 @@ def tearDown(self):
7575 def test_can_configure_schema_validation (self ):
7676 """Configure a schema for Users collection and read it back."""
7777 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME )
78- config = SchemaValidationConfiguration (
79- validators_per_collection = {"Users" : schema_def }
80- )
78+ config = SchemaValidationConfiguration (validators_per_collection = {"Users" : schema_def })
8179
8280 self .store .maintenance .send (ConfigureSchemaValidationOperation (config ))
8381
@@ -90,9 +88,7 @@ def test_can_configure_schema_validation(self):
9088 def test_schema_validation_blocks_invalid_document (self ):
9189 """Saving a document that violates the schema raises SchemaValidationException."""
9290 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME )
93- config = SchemaValidationConfiguration (
94- validators_per_collection = {"Users" : schema_def }
95- )
91+ config = SchemaValidationConfiguration (validators_per_collection = {"Users" : schema_def })
9692 self .store .maintenance .send (ConfigureSchemaValidationOperation (config ))
9793
9894 with self .assertRaises (SchemaValidationException ):
@@ -105,9 +101,7 @@ def test_schema_validation_blocks_invalid_document(self):
105101 def test_schema_validation_allows_valid_document (self ):
106102 """Saving a document that satisfies the schema succeeds."""
107103 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME )
108- config = SchemaValidationConfiguration (
109- validators_per_collection = {"Users" : schema_def }
110- )
104+ config = SchemaValidationConfiguration (validators_per_collection = {"Users" : schema_def })
111105 self .store .maintenance .send (ConfigureSchemaValidationOperation (config ))
112106
113107 with self .store .open_session () as session :
@@ -122,9 +116,7 @@ def test_schema_validation_allows_valid_document(self):
122116 def test_disabled_schema_allows_invalid_document (self ):
123117 """When the schema is disabled, invalid documents are accepted."""
124118 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME , disabled = True )
125- config = SchemaValidationConfiguration (
126- validators_per_collection = {"Users" : schema_def }
127- )
119+ config = SchemaValidationConfiguration (validators_per_collection = {"Users" : schema_def })
128120 self .store .maintenance .send (ConfigureSchemaValidationOperation (config ))
129121
130122 with self .store .open_session () as session :
@@ -168,7 +160,7 @@ def test_start_schema_validation_operation_reports_errors(self):
168160 # Insert documents without a schema active so they bypass write-time validation
169161 with self .store .open_session () as session :
170162 session .store (User (name = "Alice" ), "users/1" )
171- session .store (User (age = 30 ), "users/2" ) # missing 'name' β will fail audit
163+ session .store (User (age = 30 ), "users/2" ) # missing 'name' β will fail audit
172164 session .save_changes ()
173165
174166 params = StartSchemaValidationOperation .Parameters (
@@ -189,7 +181,7 @@ def test_start_schema_validation_operation_with_max_error_messages(self):
189181 """max_error_messages caps the number of error entries returned."""
190182 with self .store .open_session () as session :
191183 for i in range (5 ):
192- session .store (User (age = i ), f"users/{ i + 1 } " ) # all missing 'name'
184+ session .store (User (age = i ), f"users/{ i + 1 } " ) # all missing 'name'
193185 session .save_changes ()
194186
195187 params = StartSchemaValidationOperation .Parameters (
@@ -218,8 +210,8 @@ def test_validate_schema_start_etag_skips_earlier_docs(self):
218210 """
219211 # Schema that requires 'name' to be a string β both docs violate it (age-only)
220212 with self .store .open_session () as session :
221- session .store (User (age = 1 ), "users/1" ) # inserted first β lower etag
222- session .store (User (age = 2 ), "users/2" ) # inserted second β higher etag
213+ session .store (User (age = 1 ), "users/1" ) # inserted first β lower etag
214+ session .store (User (age = 2 ), "users/2" ) # inserted second β higher etag
223215 session .save_changes ()
224216
225217 params1 = StartSchemaValidationOperation .Parameters (
@@ -274,7 +266,6 @@ def test_validate_schema_max_documents_to_validate_caps_scan(self):
274266 self .assertGreater (result .last_etag , 0 )
275267
276268
277-
278269# ---------------------------------------------------------------------------
279270# Helper result class for indexing tests
280271# ---------------------------------------------------------------------------
0 commit comments