@@ -105,4 +105,44 @@ def test_file_mvd_attr():
105
105
assert f .mvd .Remark ['SomeKey' ] == 'SomeValue'
106
106
assert len (f .mvd .comments ) == 2
107
107
assert all (v in vars (f .header ).keys () for v in ['file_description' , 'file_name' , 'file_schema' ])
108
- assert len (f .header .file_name ) == 7
108
+ assert len (f .header .file_name ) == 7
109
+
110
+
111
+ @pytest .mark .parametrize ("filename" , [
112
+ 'fixtures/fail_invalid_header_entity.ifc' ,
113
+ 'fixtures/fail_no_header.ifc' ,
114
+ ])
115
+ def test_invalid_headers_ (filename ):
116
+ # error in header; with_header should raise an error
117
+ with pytest .raises (ValidationError ):
118
+ parse (filename = filename , with_tree = False , only_header = True , with_header = True )
119
+
120
+ @pytest .mark .parametrize ("filename" , [
121
+ 'fixtures/fail_duplicate_id.ifc' ,
122
+ 'fixtures/fail_double_comma.ifc' ,
123
+ 'fixtures/fail_double_semi.ifc'
124
+ ])
125
+ def test_valid_headers (filename ):
126
+ # error in body; with_header should not raise an error
127
+ with nullcontext ():
128
+ parse (filename = filename , with_tree = False , only_header = True , with_header = True )
129
+
130
+
131
+ @pytest .mark .parametrize ("filename" , [
132
+ 'fixtures/fail_invalid_header_entity.ifc' ,
133
+ 'fixtures/fail_no_header.ifc' ,
134
+ ])
135
+ def test_invalid_headers_ (filename ):
136
+ # error in header; validate_data_only should not raise an error
137
+ with nullcontext ():
138
+ parse (filename = filename , validate_data_only = True )
139
+
140
+ @pytest .mark .parametrize ("filename" , [
141
+ 'fixtures/fail_duplicate_id.ifc' ,
142
+ 'fixtures/fail_double_comma.ifc' ,
143
+ 'fixtures/fail_double_semi.ifc'
144
+ ])
145
+ def test_valid_headers (filename ):
146
+ # error in body; validate_data_only should raise an error
147
+ with pytest .raises (ValidationError ):
148
+ parse (filename = filename , validate_data_only = True )
0 commit comments