Skip to content

Commit

Permalink
Change deprecated assertEquals
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed May 7, 2024
1 parent 6d615b1 commit 7e3fdc6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
40 changes: 20 additions & 20 deletions app/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def test_manageinf_stop(self, flash, avatar, put, user_data):
res = self.client.post('/manage_inf/infid/stop')
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0],
self.assertEqual(flash.call_args_list[0][0],
("Operation 'stop' successfully made on Infrastructure ID: infid", 'success'))

@patch("app.utils.getUserAuthData")
Expand All @@ -268,7 +268,7 @@ def test_manageinf_change_user(self, flash, avatar, post, user_data):
res = self.client.post('/manage_inf/infid/change_user', data=params)
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0],
self.assertEqual(flash.call_args_list[0][0],
("Infrastructure owner successfully changed.", 'success'))

@patch("app.utils.getUserAuthData")
Expand All @@ -284,7 +284,7 @@ def test_manageinf_migrate(self, flash, avatar, get, put, user_data):
res = self.client.post('/manage_inf/infid/migrate', data={"new_im_url": "http://newim.com/im"})
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0],
self.assertEqual(flash.call_args_list[0][0],
("Infrastructure successfully migrated to http://server.com/im/infrastructures/infid.",
'success'))

Expand All @@ -311,7 +311,7 @@ def test_managevm_stop(self, flash, avatar, put, user_data):
res = self.client.post('/managevm/stop/infid/0')
self.assertEqual(302, res.status_code)
self.assertIn('/vminfo?infId=infid&vmId=0', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("Operation 'stop' successfully made on VM ID: 0", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("Operation 'stop' successfully made on VM ID: 0", 'success'))

@patch("app.utils.getUserAuthData")
@patch('requests.delete')
Expand All @@ -324,7 +324,7 @@ def test_managevm_delete(self, flash, avatar, delete, user_data):
res = self.client.post('/managevm/terminate/infid/0')
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("Operation 'terminate' successfully made on VM ID: 0",
self.assertEqual(flash.call_args_list[0][0], ("Operation 'terminate' successfully made on VM ID: 0",
'success'))

@patch("app.utils.getUserAuthData")
Expand All @@ -344,7 +344,7 @@ def test_managevm_resize(self, flash, avatar, put, get, user_data):
res = self.client.post('/managevm/resize/infid/0', data=params)
self.assertEqual(302, res.status_code)
self.assertIn('/vminfo?infId=infid&vmId=0', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("Operation 'resize' successfully made on VM ID: 0", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("Operation 'resize' successfully made on VM ID: 0", 'success'))

@patch("app.utils.getUserAuthData")
@patch('requests.put')
Expand All @@ -357,7 +357,7 @@ def test_reconfigure(self, flash, avatar, put, user_data):
res = self.client.post('/manage_inf/infid/reconfigure')
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("Reconfiguration process successfuly started.", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("Reconfiguration process successfuly started.", 'success'))

@patch("app.utils.getUserAuthData")
@patch('requests.get')
Expand Down Expand Up @@ -418,7 +418,7 @@ def test_delete(self, flash, avatar, delete, user_data):
res = self.client.post('/manage_inf/infid/delete')
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("Infrastructure 'infid' successfuly deleted.", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("Infrastructure 'infid' successfuly deleted.", 'success'))

@patch("app.utils.avatar")
@patch("app.db_cred.DBCredentials.get_creds")
Expand Down Expand Up @@ -506,7 +506,7 @@ def test_submit(self, flash, get_ssh_keys, get_cred, get_site_info, avatar, post
res = self.client.post('/submit?template=simple-node-disk.yml', data=params)
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_count, 0)
self.assertEqual(flash.call_count, 0)

@patch('app.utils.get_site_info')
@patch("app.utils.getUserAuthData")
Expand All @@ -532,7 +532,7 @@ def test_submit2(self, flash, get_cred, avatar, post, user_data, get_site_info):
res = self.client.post('/submit?template=simple-node-disk.yml', data=params)
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_count, 0)
self.assertEqual(flash.call_count, 0)

@patch("app.utils.getUserAuthData")
@patch('requests.post')
Expand All @@ -556,7 +556,7 @@ def test_submit_tosca(self, flash, get_cred, get_site_info, avatar, post, user_d
res = self.client.post('/submit?template=tosca.yml', data=params)
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_count, 0)
self.assertEqual(flash.call_count, 0)

@patch("app.utils.avatar")
@patch("app.db_cred.DBCredentials.get_creds")
Expand Down Expand Up @@ -596,17 +596,17 @@ def test_write_creds(self, flash, write_creds, get_cred, avatar):
"type": "OpenNebula"})
self.assertEqual(302, res.status_code)
self.assertIn('/manage_creds', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("Credentials successfully written!", 'success'))
self.assertEquals(write_creds.call_args_list[0][0], ('credid', 'userid', {'host': 'SITE_URL2',
self.assertEqual(flash.call_args_list[0][0], ("Credentials successfully written!", 'success'))
self.assertEqual(write_creds.call_args_list[0][0], ('credid', 'userid', {'host': 'SITE_URL2',
'id': 'credid', 'type': "OpenNebula"}, False))

res = self.client.post('/write_creds?cred_id=&cred_type=OpenNebula', data={"host": "SITE_URL3",
"id": "credid",
"type": "OpenNebula"})
self.assertEqual(302, res.status_code)
self.assertIn('/manage_creds', res.headers['location'])
self.assertEquals(flash.call_args_list[1][0], ("Credentials successfully written!", 'success'))
self.assertEquals(write_creds.call_args_list[1][0], ('credid', 'userid', {'host': 'SITE_URL3',
self.assertEqual(flash.call_args_list[1][0], ("Credentials successfully written!", 'success'))
self.assertEqual(write_creds.call_args_list[1][0], ('credid', 'userid', {'host': 'SITE_URL3',
'id': 'credid',
'type': 'OpenNebula'}, True))

Expand All @@ -619,7 +619,7 @@ def test_delete_creds(self, flash, delete_cred, avatar):
res = self.client.get('/delete_creds?service_id=SERVICE_ID')
self.assertEqual(302, res.status_code)
self.assertIn('/manage_creds', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("Credentials successfully deleted!", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("Credentials successfully deleted!", 'success'))

@patch("app.utils.getUserAuthData")
@patch('requests.get')
Expand All @@ -645,7 +645,7 @@ def test_addresources(self, flash, avatar, post, get, user_data):
self.login(avatar)
res = self.client.post('/addresources/infid', data={"wn_num": "1"})
self.assertEqual(302, res.status_code)
self.assertEquals(flash.call_args_list[0][0], ("1 nodes added successfully", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("1 nodes added successfully", 'success'))

@patch("app.utils.avatar")
@patch("app.utils.getUserAuthData")
Expand All @@ -662,7 +662,7 @@ def test_quotas(self, get, user_data, avatar):
"instances": {"used": 1, "limit": 10},
"floating_ips": {"used": 1, "limit": 10},
"security_groups": {"used": 1, "limit": 10}}
self.assertEquals(expected_res, json.loads(res.data))
self.assertEqual(expected_res, json.loads(res.data))

@patch("app.utils.avatar")
@patch("app.ssh_key.SSHKey.get_ssh_keys")
Expand Down Expand Up @@ -697,7 +697,7 @@ def test_delete_ssh_key(self, flash, delete_ssh_key, avatar):
res = self.client.get('/delete_ssh_key?ssh_id=1')
self.assertEqual(302, res.status_code)
self.assertIn('/ssh_key', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("SSH Key successfully deleted!", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("SSH Key successfully deleted!", 'success'))

@patch("app.utils.getUserAuthData")
@patch('requests.delete')
Expand All @@ -710,7 +710,7 @@ def test_removeresources(self, flash, avatar, delete, user_data):
res = self.client.post('/manage_inf/infid/removeresources', data={'vm_list': '1,2'})
self.assertEqual(302, res.status_code)
self.assertIn('/infrastructures', res.headers['location'])
self.assertEquals(flash.call_args_list[0][0], ("VMs 1,2 successfully deleted.", 'success'))
self.assertEqual(flash.call_args_list[0][0], ("VMs 1,2 successfully deleted.", 'success'))

@patch("app.utils.getUserAuthData")
@patch('requests.get')
Expand Down
8 changes: 4 additions & 4 deletions app/tests/test_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ def test_get_infra(self):
res.close()

res = infra.get_infra("infid")
self.assertEquals(res, {'name': 'infra_name'})
self.assertEqual(res, {'name': 'infra_name'})

def test_write_infra(self):
infra = Infrastructures("sqlite:///tmp/creds.db")
infra.write_infra("infid", {"name": "infra_name"})
res = infra.get_infra("infid")
self.assertEquals(res, {"name": "infra_name"})
self.assertEqual(res, {"name": "infra_name"})
infra.write_infra("infid", {"state": "infra_state"})
res = infra.get_infra("infid")
self.assertEquals(res, {"name": "infra_name", "state": "infra_state"})
self.assertEqual(res, {"name": "infra_name", "state": "infra_state"})

def test_delete_infra(self):
infra = Infrastructures("sqlite:///tmp/creds.db")
infra.delete_infra("infid")
res = infra.get_infra("infid")
self.assertEquals(res, {})
self.assertEqual(res, {})


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions app/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_getUserVOs(self):
'urn:mace:egi.eu:group:vo.test.egi.eu:role=vm_operator#aai.egi.eu',
'urn:mace:egi.eu:group:vo.test2.egi.eu:role=member#aai.egi.eu']
res = utils.getUserVOs(entitlements)
self.assertEquals(res, ['vo.test.egi.eu', 'vo.test2.egi.eu'])
self.assertEqual(res, ['vo.test.egi.eu', 'vo.test2.egi.eu'])

@patch("app.utils.getCachedProjectIDs")
@patch("app.utils.getCachedSiteList")
Expand All @@ -52,7 +52,7 @@ def test_getUserAuthData(self, getCachedSiteList, getCachedProjectIDs):
flask_context.g.settings = MagicMock()
flask_context.g.settings.im_auth = ""
res = utils.getUserAuthData("token", cred, "user")
self.assertEquals(res, ("type = InfrastructureManager; token = token\\nid = one; type = 'OpenNebula';"
self.assertEqual(res, ("type = InfrastructureManager; token = token\\nid = one; type = 'OpenNebula';"
" username = 'user'; password = 'pass'\\n"
"id = fed; type = OpenStack; username = egi.eu;"
" tenant = oidc; auth_version = 3.x_oidc_access_token; host ="
Expand All @@ -64,7 +64,7 @@ def test_getUserAuthData(self, getCachedSiteList, getCachedProjectIDs):

flask_context.g.settings.im_auth = "Bearer"
res = utils.getUserAuthData("token", cred, "user")
self.assertEquals(res, ("Bearer token"))
self.assertEqual(res, ("Bearer token"))

def test_merge_template(self):
template = {"topology_template": {"node_templates": {"n1": {"type": "Compute"}}}}
Expand Down

0 comments on commit 7e3fdc6

Please sign in to comment.