@@ -614,27 +614,68 @@ async def test_store_async_no_default_columns(self):
614
614
# AND the result should be the same instance
615
615
assert result == test_instance
616
616
617
- async def test_store_async_invalid_character_in_column_name (self ):
618
- # GIVEN a TestClass instance with an invalid character in a column name
619
- test_instance = self .ClassForTest (
617
+ @pytest .mark .parametrize (
618
+ "invalid_column_name" ,
619
+ [
620
+ "col*1" , # Invalid character: *
621
+ "col/1" , # Invalid character: /
622
+ "col\\ 1" , # Invalid character: \
623
+ "col:1" , # Invalid character: :
624
+ "col;1" , # Invalid character: ;
625
+ "col,1" , # Invalid character: ,
626
+ "col?1" , # Invalid character: ?
627
+ "col!1" , # Invalid character: !
628
+ "col@1" , # Invalid character: @
629
+ "col#1" , # Invalid character: #
630
+ ],
631
+ )
632
+ async def test_store_async_invalid_character_in_column_name (
633
+ self , invalid_column_name
634
+ ):
635
+ # GIVEN a TestClass instance with an invalid column name
636
+ test_instance = TestViewStoreMixin .ClassForTest (
620
637
include_default_columns = False ,
621
638
columns = {
622
- "col*1" : Column (name = "col*1" , column_type = ColumnType .STRING , id = "id1" )
639
+ invalid_column_name : Column (
640
+ name = invalid_column_name , column_type = ColumnType .STRING , id = "id1"
641
+ )
623
642
},
624
643
)
625
644
626
- with patch (GET_ID_PATCH , return_value = None ):
627
- # WHEN store_async is awaited
628
- # THEN a ValueError should be raised
629
- with pytest .raises (
630
- ValueError ,
631
- match = re .escape (
632
- "Column name 'col*1' contains invalid characters. "
633
- "Names may only contain: letters, numbers, spaces, underscores, "
634
- "hyphens, periods, plus signs, apostrophes, and parentheses."
645
+ # WHEN store_async is awaited
646
+ # THEN a ValueError should be raised with the appropriate message
647
+ with pytest .raises (
648
+ ValueError ,
649
+ match = re .escape (
650
+ f"Column name '{ invalid_column_name } ' contains invalid characters. "
651
+ "Names may only contain: letters, numbers, spaces, underscores, "
652
+ "hyphens, periods, plus signs, apostrophes, and parentheses."
653
+ ),
654
+ ):
655
+ await test_instance .store_async (synapse_client = None , dry_run = True )
656
+
657
+ async def test_store_async_valid_characters_in_column_name (self ):
658
+ # GIVEN a TestClass instance with valid characters in column names
659
+ test_instance = self .ClassForTest (
660
+ include_default_columns = False ,
661
+ columns = {
662
+ "col1" : Column (name = "col1" , column_type = ColumnType .STRING , id = "id1" ),
663
+ "col 2" : Column (name = "col 2" , column_type = ColumnType .STRING , id = "id2" ),
664
+ "col_3" : Column (name = "col_3" , column_type = ColumnType .STRING , id = "id3" ),
665
+ "col-4" : Column (name = "col-4" , column_type = ColumnType .STRING , id = "id4" ),
666
+ "col.5" : Column (name = "col.5" , column_type = ColumnType .STRING , id = "id5" ),
667
+ "col+6" : Column (name = "col+6" , column_type = ColumnType .STRING , id = "id6" ),
668
+ "col'7" : Column (name = "col'7" , column_type = ColumnType .STRING , id = "id7" ),
669
+ "col(8)" : Column (
670
+ name = "col(8)" , column_type = ColumnType .STRING , id = "id8"
635
671
),
636
- ):
637
- await test_instance .store_async (synapse_client = self .syn , dry_run = True )
672
+ },
673
+ )
674
+
675
+ # WHEN store_async is awaited
676
+ await test_instance .store_async (synapse_client = self .syn , dry_run = True )
677
+
678
+ # THEN No exception should be raised
638
679
639
680
640
681
class TestDeleteMixin :
0 commit comments