@@ -35,6 +35,7 @@ def generate_default_compact_config_overrides():
35
35
'compactAbbr' : TEST_COMPACT_ABBR ,
36
36
'compactName' : TEST_COMPACT_NAME ,
37
37
'licenseeRegistrationEnabled' : True ,
38
+ 'configuredStates' : [{'postalAbbreviation' : MOCK_JURISDICTION_POSTAL_ABBR , 'isLive' : True }],
38
39
}
39
40
40
41
@@ -168,32 +169,70 @@ def test_registration_returns_400_if_compact_is_not_enabled_for_registration(sel
168
169
)
169
170
170
171
@patch ('handlers.registration.verify_recaptcha' )
171
- def test_registration_returns_400_if_jurisdiction_is_not_enabled_for_registration (self , mock_verify_recaptcha ):
172
- jurisdiction_config_overrides = generate_default_jurisdiction_config_overrides ()
173
- # in this case, no environments are enabled for registration
174
- jurisdiction_config_overrides .update ({'licenseeRegistrationEnabled' : False })
175
- self ._load_jurisdiction_configuration (overrides = jurisdiction_config_overrides )
172
+ def test_registration_returns_400_if_jurisdiction_is_not_configured_for_registration (self , mock_verify_recaptcha ):
176
173
mock_verify_recaptcha .return_value = True
177
174
from handlers .registration import register_provider
178
175
176
+ response = register_provider (self ._get_test_event (body_overrides = {'jurisdiction' : 'oh' }), self .mock_context )
177
+ self .assertEqual (400 , response ['statusCode' ])
178
+ self .assertEqual (
179
+ {'message' : 'Registration is not currently available for the specified state.' },
180
+ json .loads (response ['body' ]),
181
+ )
182
+
183
+ @patch ('handlers.registration.verify_recaptcha' )
184
+ def test_registration_returns_400_if_jurisdiction_not_in_configured_states (self , mock_verify_recaptcha ):
185
+ """Test that registration is rejected if jurisdiction is not in compact's configuredStates."""
186
+ mock_verify_recaptcha .return_value = True
187
+
188
+ # Update compact configuration to have empty configuredStates
189
+ compact_config_overrides = generate_default_compact_config_overrides ()
190
+ compact_config_overrides .update ({'configuredStates' : []})
191
+ self ._load_compact_configuration (overrides = compact_config_overrides )
192
+
193
+ from handlers .registration import register_provider
194
+
179
195
response = register_provider (self ._get_test_event (), self .mock_context )
180
196
self .assertEqual (400 , response ['statusCode' ])
181
197
self .assertEqual (
182
- {'message' : 'Registration is not currently available for Kentucky.' }, json .loads (response ['body' ])
198
+ {'message' : 'Registration is not currently available for Kentucky.' },
199
+ json .loads (response ['body' ]),
183
200
)
184
201
185
202
@patch ('handlers.registration.verify_recaptcha' )
186
- def test_registration_returns_400_if_jurisdiction_is_not_configured_for_registration (self , mock_verify_recaptcha ):
203
+ def test_registration_returns_400_if_jurisdiction_not_live_in_configured_states (self , mock_verify_recaptcha ):
204
+ """Test that registration is rejected if jurisdiction is not live in compact's configuredStates."""
187
205
mock_verify_recaptcha .return_value = True
206
+
207
+ # Update compact configuration to have jurisdiction but not live
208
+ compact_config_overrides = generate_default_compact_config_overrides ()
209
+ compact_config_overrides .update (
210
+ {'configuredStates' : [{'postalAbbreviation' : MOCK_JURISDICTION_POSTAL_ABBR , 'isLive' : False }]}
211
+ )
212
+ self ._load_compact_configuration (overrides = compact_config_overrides )
213
+
188
214
from handlers .registration import register_provider
189
215
190
- response = register_provider (self ._get_test_event (body_overrides = { 'jurisdiction' : 'oh' } ), self .mock_context )
216
+ response = register_provider (self ._get_test_event (), self .mock_context )
191
217
self .assertEqual (400 , response ['statusCode' ])
192
218
self .assertEqual (
193
- {'message' : 'Registration is not currently available for the specified state .' },
219
+ {'message' : 'Registration is not currently available for Kentucky .' },
194
220
json .loads (response ['body' ]),
195
221
)
196
222
223
+ @patch ('handlers.registration.verify_recaptcha' )
224
+ def test_registration_succeeds_if_jurisdiction_is_live_in_configured_states (self , mock_verify_recaptcha ):
225
+ """Test that registration succeeds if jurisdiction is live in compact's configuredStates."""
226
+ mock_verify_recaptcha .return_value = True
227
+ self ._add_mock_provider_records ()
228
+
229
+ # Default setup already has jurisdiction as live in configuredStates
230
+ from handlers .registration import register_provider
231
+
232
+ response = register_provider (self ._get_test_event (), self .mock_context )
233
+ self .assertEqual (200 , response ['statusCode' ])
234
+ self .assertEqual ({'message' : 'request processed' }, json .loads (response ['body' ]))
235
+
197
236
@patch ('handlers.registration.verify_recaptcha' )
198
237
def test_registration_returns_403_if_recaptcha_fails (self , mock_verify_recaptcha ):
199
238
mock_verify_recaptcha .return_value = False
0 commit comments