11import json
2+ import os
3+ import unittest
24
35from ravendb .documents .indexes .definitions import FieldStorage , IndexDefinition , IndexFieldOptions
46from ravendb .documents .operations .indexes import PutIndexesOperation , ResetIndexOperation
@@ -72,6 +74,7 @@ def tearDown(self):
7274 # Ported from SchemaValidationBasicTests.cs
7375 # ------------------------------------------------------------------
7476
77+ @unittest .skipIf (os .environ .get ("RAVENDB_LICENSE" ) is None , "Insufficient license permissions. Skipping on CI/CD." )
7578 def test_can_configure_schema_validation (self ):
7679 """Configure a schema for Users collection and read it back."""
7780 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME )
@@ -85,6 +88,7 @@ def test_can_configure_schema_validation(self):
8588 stored = result .validators_per_collection ["Users" ]
8689 self .assertEqual (_SCHEMA_REQUIRE_NAME , stored .schema )
8790
91+ @unittest .skipIf (os .environ .get ("RAVENDB_LICENSE" ) is None , "Insufficient license permissions. Skipping on CI/CD." )
8892 def test_schema_validation_blocks_invalid_document (self ):
8993 """Saving a document that violates the schema raises SchemaValidationException."""
9094 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME )
@@ -98,6 +102,7 @@ def test_schema_validation_blocks_invalid_document(self):
98102 session .store (user , "users/1" )
99103 session .save_changes ()
100104
105+ @unittest .skipIf (os .environ .get ("RAVENDB_LICENSE" ) is None , "Insufficient license permissions. Skipping on CI/CD." )
101106 def test_schema_validation_allows_valid_document (self ):
102107 """Saving a document that satisfies the schema succeeds."""
103108 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME )
@@ -113,6 +118,7 @@ def test_schema_validation_allows_valid_document(self):
113118 loaded = session .load ("users/1" , User )
114119 self .assertEqual ("Alice" , loaded .name )
115120
121+ @unittest .skipIf (os .environ .get ("RAVENDB_LICENSE" ) is None , "Insufficient license permissions. Skipping on CI/CD." )
116122 def test_disabled_schema_allows_invalid_document (self ):
117123 """When the schema is disabled, invalid documents are accepted."""
118124 schema_def = SchemaDefinition (schema = _SCHEMA_REQUIRE_NAME , disabled = True )
@@ -333,10 +339,11 @@ def test_indexing_schema_errors_when_fails_one_rule_should_get_the_error(self):
333339 )
334340 by_id = {r .Id : r for r in results }
335341
336- self .assertIsNone (by_id [valid_doc_id ].Errors )
342+ # Server returns None or [] for a valid document
343+ self .assertFalse (by_id [valid_doc_id ].Errors )
337344
338345 errors = by_id [invalid_doc_id ].Errors
339- self .assertIsNotNone (errors )
346+ self .assertTrue (errors )
340347 self .assertEqual (1 , len (errors ))
341348 self .assertIn ("Prop" , errors [0 ])
342349
@@ -396,6 +403,7 @@ def test_indexing_schema_errors_when_define_schema_on_metadata_should_reject(sel
396403 # ------------------------------------------------------------------
397404 # IndexingSchemaErrors_WhenSchemaDefinedInDatabase_ShouldIndexErrors
398405 # ------------------------------------------------------------------
406+ @unittest .skipIf (os .environ .get ("RAVENDB_LICENSE" ) is None , "Insufficient license permissions. Skipping on CI/CD." )
399407 def test_indexing_schema_errors_when_schema_defined_in_database_should_index_errors (self ):
400408 """
401409 When no schema_definitions are set on the index itself, but a database-level
@@ -431,9 +439,10 @@ def test_indexing_schema_errors_when_schema_defined_in_database_should_index_err
431439 )
432440 by_id = {r .Id : r for r in results }
433441
434- self .assertIsNone (by_id [valid_doc_id ].Errors )
442+ # Server returns None or [] for a valid document
443+ self .assertFalse (by_id [valid_doc_id ].Errors )
435444
436445 errors = by_id [invalid_doc_id ].Errors
437- self .assertIsNotNone (errors )
446+ self .assertTrue (errors )
438447 self .assertEqual (1 , len (errors ))
439448 self .assertIn ("Prop" , errors [0 ])
0 commit comments