@@ -89,9 +89,7 @@ def test_patch_invalid_auth_backend(
8989 )
9090 assert response .status_code == status .HTTP_400_BAD_REQUEST
9191 assert 'auth_backend' in response .data
92- assert 'is not a valid choice' in str (
93- response .data ['auth_backend' ]
94- )
92+ assert 'is not a valid choice' in str (response .data ['auth_backend' ])
9593 settings_mock .load .assert_not_called ()
9694 settings_mock .save .assert_not_called ()
9795
@@ -133,10 +131,7 @@ def test_patch_success(
133131 device_settings_url , data = data , format = 'json'
134132 )
135133 assert response .status_code == status .HTTP_200_OK
136- assert (
137- response .data ['message' ]
138- == 'Settings were successfully saved.'
139- )
134+ assert response .data ['message' ] == 'Settings were successfully saved.'
140135 settings_mock .load .assert_called_once ()
141136 settings_mock .save .assert_called_once ()
142137 assert settings_mock .__setitem__ .call_count == 5
@@ -214,21 +209,12 @@ def test_enable_basic_auth(
214209 device_settings_url , data = data , format = 'json'
215210 )
216211 assert response .status_code == status .HTTP_200_OK
217- assert (
218- response .data ['message' ]
219- == 'Settings were successfully saved.'
220- )
212+ assert response .data ['message' ] == 'Settings were successfully saved.'
221213 settings_mock .load .assert_called_once ()
222214 settings_mock .save .assert_called_once ()
223- settings_mock .__setitem__ .assert_any_call (
224- 'auth_backend' , 'auth_basic'
225- )
226- settings_mock .__setitem__ .assert_any_call (
227- 'user' , 'testuser'
228- )
229- settings_mock .__setitem__ .assert_any_call (
230- 'password' , expected_hashed
231- )
215+ settings_mock .__setitem__ .assert_any_call ('auth_backend' , 'auth_basic' )
216+ settings_mock .__setitem__ .assert_any_call ('user' , 'testuser' )
217+ settings_mock .__setitem__ .assert_any_call ('password' , expected_hashed )
232218 send_to_viewer_mock .assert_called_once_with ('reload' )
233219
234220 @patch ('api.views.v2.settings' )
@@ -273,15 +259,10 @@ def test_disable_basic_auth(
273259 device_settings_url , data = data , format = 'json'
274260 )
275261 assert response .status_code == status .HTTP_200_OK
276- assert (
277- response .data ['message' ]
278- == 'Settings were successfully saved.'
279- )
262+ assert response .data ['message' ] == 'Settings were successfully saved.'
280263 settings_mock .load .assert_called_once ()
281264 settings_mock .save .assert_called_once ()
282- settings_mock .__setitem__ .assert_any_call (
283- 'auth_backend' , ''
284- )
265+ settings_mock .__setitem__ .assert_any_call ('auth_backend' , '' )
285266 send_to_viewer_mock .assert_called_once_with ('reload' )
286267
287268 response = api_client .get (device_settings_url )
@@ -324,15 +305,10 @@ def test_patch_default_assets(
324305 format = 'json' ,
325306 )
326307 assert response .status_code == status .HTTP_200_OK
327- assert (
328- response .data ['message' ]
329- == 'Settings were successfully saved.'
330- )
308+ assert response .data ['message' ] == 'Settings were successfully saved.'
331309 settings_mock .load .assert_called_once ()
332310 settings_mock .save .assert_called_once ()
333- settings_mock .__setitem__ .assert_any_call (
334- 'default_assets' , True
335- )
311+ settings_mock .__setitem__ .assert_any_call ('default_assets' , True )
336312 add_default_assets_mock .assert_called_once ()
337313 remove_default_assets_mock .assert_not_called ()
338314 send_to_viewer_mock .assert_called_once_with ('reload' )
@@ -367,15 +343,10 @@ def test_patch_default_assets(
367343 format = 'json' ,
368344 )
369345 assert response .status_code == status .HTTP_200_OK
370- assert (
371- response .data ['message' ]
372- == 'Settings were successfully saved.'
373- )
346+ assert response .data ['message' ] == 'Settings were successfully saved.'
374347 settings_mock .load .assert_called_once ()
375348 settings_mock .save .assert_called_once ()
376- settings_mock .__setitem__ .assert_any_call (
377- 'default_assets' , False
378- )
349+ settings_mock .__setitem__ .assert_any_call ('default_assets' , False )
379350 remove_default_assets_mock .assert_called_once ()
380351 add_default_assets_mock .assert_not_called ()
381352 send_to_viewer_mock .assert_called_once_with ('reload' )
@@ -390,20 +361,14 @@ def setup(self):
390361
391362 @patch ('api.views.v2.is_balena_app' )
392363 @patch ('api.views.v2.getenv' )
393- def test_balena_environment (
394- self , mock_getenv , mock_is_balena
395- ):
364+ def test_balena_environment (self , mock_getenv , mock_is_balena ):
396365 mock_is_balena .side_effect = lambda : True
397366 mock_getenv .side_effect = lambda x : {
398367 'BALENA_DEVICE_UUID' : 'test-device-uuid' ,
399368 'BALENA_APP_ID' : 'test-app-id' ,
400369 'BALENA_APP_NAME' : 'test-app-name' ,
401- 'BALENA_SUPERVISOR_VERSION' : (
402- 'test-supervisor-version'
403- ),
404- 'BALENA_HOST_OS_VERSION' : (
405- 'test-host-os-version'
406- ),
370+ 'BALENA_SUPERVISOR_VERSION' : ('test-supervisor-version' ),
371+ 'BALENA_HOST_OS_VERSION' : ('test-host-os-version' ),
407372 'BALENA_DEVICE_NAME_AT_INIT' : 'test-device-name' ,
408373 }.get (x )
409374
@@ -414,12 +379,8 @@ def test_balena_environment(
414379 'balena_device_id' : 'test-device-uuid' ,
415380 'balena_app_id' : 'test-app-id' ,
416381 'balena_app_name' : 'test-app-name' ,
417- 'balena_supervisor_version' : (
418- 'test-supervisor-version'
419- ),
420- 'balena_host_os_version' : (
421- 'test-host-os-version'
422- ),
382+ 'balena_supervisor_version' : ('test-supervisor-version' ),
383+ 'balena_host_os_version' : ('test-host-os-version' ),
423384 'balena_device_name_at_init' : 'test-device-name' ,
424385 }
425386
0 commit comments