|
8 | 8 | DaemonConfig,
|
9 | 9 | LoggingConfig,
|
10 | 10 | ReportsConfig,
|
| 11 | + StorageConfig, |
11 | 12 | validate_config,
|
12 | 13 | )
|
13 | 14 |
|
@@ -169,6 +170,45 @@ def test_classifier_config_validate():
|
169 | 170 | ]
|
170 | 171 |
|
171 | 172 |
|
| 173 | +def test_storage_config_validate(): |
| 174 | + # Test with storage type `file` correct value |
| 175 | + storage = {"type": "file"} |
| 176 | + validator = StorageConfig(storage) |
| 177 | + validator.validate() |
| 178 | + assert validator.errors == [] |
| 179 | + |
| 180 | + # Test with storage type `db` correct value |
| 181 | + storage = {"type": "db", "db": "sqlite", "name": "pebblo_db"} |
| 182 | + validator = StorageConfig(storage) |
| 183 | + validator.validate() |
| 184 | + assert validator.errors == [] |
| 185 | + |
| 186 | + # Test with wrong storage type |
| 187 | + storage = {"type": "xyz"} |
| 188 | + validator = StorageConfig(storage) |
| 189 | + validator.validate() |
| 190 | + assert validator.errors == [ |
| 191 | + "Error: Unsupported storage type 'xyz' specified in the configuration.Valid values are ['file', 'db']" |
| 192 | + ] |
| 193 | + |
| 194 | + # Test with storage type as `db` wrong `db` value |
| 195 | + storage = {"type": "db", "db": "db123", "name": "pebblo_db"} |
| 196 | + validator = StorageConfig(storage) |
| 197 | + validator.validate() |
| 198 | + assert validator.errors == [ |
| 199 | + "Error: Unsupported db type 'db123' specified in the configuration.Valid values are ['sqlite']" |
| 200 | + ] |
| 201 | + |
| 202 | + # Test with storage type as `db` without `db` and `name` |
| 203 | + storage = {"type": "db"} |
| 204 | + validator = StorageConfig(storage) |
| 205 | + validator.validate() |
| 206 | + assert validator.errors == [ |
| 207 | + "Error: Unsupported db type 'None' specified in the configuration.Valid values are ['sqlite']", |
| 208 | + "Error: Unsupported db name 'None specified in the configurationString values are allowed only", |
| 209 | + ] |
| 210 | + |
| 211 | + |
172 | 212 | def test_validate_config(setup_and_teardown):
|
173 | 213 | # Test with valid configuration
|
174 | 214 | config = {
|
|
0 commit comments