Update dependencies, fix tests
- replace assertTrue(mock.called_with(...)) with mock.assert_called_with
This commit is contained in:
parent
f3ef40df0b
commit
38b120b03e
6 changed files with 516 additions and 452 deletions
|
@ -119,13 +119,13 @@ class ActivationChangeMixinTest(TestCase):
|
|||
querysetmock = Mock()
|
||||
activationchange = ActivationChangeMixin()
|
||||
activationchange.activate(Mock(), querysetmock)
|
||||
querysetmock.update.called_with(active=True)
|
||||
querysetmock.update.assert_called_with(active=True)
|
||||
|
||||
def test_deactivate(self):
|
||||
querysetmock = Mock()
|
||||
activationchange = ActivationChangeMixin()
|
||||
activationchange.deactivate(Mock(), querysetmock)
|
||||
querysetmock.update.called_with(active=False)
|
||||
querysetmock.update.assert_called_with(active=False)
|
||||
|
||||
|
||||
class MailBoxAdminTest(CustomerTestCase):
|
||||
|
|
|
@ -35,8 +35,8 @@ class FetchTaskResultsCommandTest(TestCase):
|
|||
Command().handle(verbosity=0)
|
||||
|
||||
tr = TaskResult.objects.get(task_id=TEST_TASK_UUID)
|
||||
self.assertTrue(asyncresult.called_with(TEST_TASK_UUID))
|
||||
self.assertTrue(aresult.ready.called_with())
|
||||
asyncresult.assert_called_with(TEST_TASK_UUID)
|
||||
aresult.ready.assert_called_with()
|
||||
self.assertFalse(tr.finished)
|
||||
self.assertEqual(tr.result, "")
|
||||
self.assertEqual(tr.state, "PENDING")
|
||||
|
@ -58,9 +58,9 @@ class FetchTaskResultsCommandTest(TestCase):
|
|||
Command().handle(verbosity=0)
|
||||
|
||||
tr = TaskResult.objects.get(task_id=TEST_TASK_UUID)
|
||||
self.assertTrue(asyncresult.called_with(TEST_TASK_UUID))
|
||||
self.assertTrue(aresult.ready.called_with())
|
||||
self.assertTrue(aresult.get.called_with())
|
||||
asyncresult.assert_called_with(TEST_TASK_UUID)
|
||||
aresult.ready.assert_called_with()
|
||||
aresult.get.assert_called_with(propagate=False, timeout=5)
|
||||
self.assertTrue(tr.finished)
|
||||
self.assertEqual(tr.result, TEST_TASK_RESULT)
|
||||
self.assertEqual(tr.state, "SUCCESS")
|
||||
|
|
|
@ -41,7 +41,7 @@ class TaskResultTest(TestCase):
|
|||
aresult.ready.return_value = True
|
||||
aresult.get.return_value = TEST_TASK_RESULT
|
||||
tr.fetch_result()
|
||||
self.assertTrue(aresult.get.called_with())
|
||||
aresult.get.assert_called_with(propagate=False, timeout=5)
|
||||
self.assertEqual(aresult.get.call_count, 1)
|
||||
self.assertTrue(tr.finished)
|
||||
self.assertEqual(tr.result, str(TEST_TASK_RESULT))
|
||||
|
|
|
@ -24,10 +24,8 @@ class DatabaseUserCreationFormTest(TestCase):
|
|||
mockuser = Mock(name="osuser")
|
||||
form.cleaned_data = {"osuser": mockuser, "db_type": DB_TYPES.pgsql}
|
||||
retval = form.save()
|
||||
self.assertTrue(
|
||||
create_database_user.called_with(
|
||||
osuser=mockuser, db_type=DB_TYPES.pgsql, commit=True
|
||||
)
|
||||
create_database_user.assert_called_with(
|
||||
osuser=mockuser, db_type=DB_TYPES.pgsql, commit=True
|
||||
)
|
||||
self.assertEqual(retval, create_database_user.return_value)
|
||||
|
||||
|
@ -44,7 +42,7 @@ class UserDatabaseCreationFormTest(TestCase):
|
|||
mockuser = Mock(name="mockuser")
|
||||
form.cleaned_data = {"db_user": mockuser}
|
||||
retval = form.save()
|
||||
self.assertTrue(create_userdatabase.called_with(db_user=mockuser, commit=True))
|
||||
create_userdatabase.assert_called_with(db_user=mockuser, commit=True)
|
||||
self.assertEqual(retval, create_userdatabase.return_value)
|
||||
|
||||
def test_save_m2m_returns_none(self):
|
||||
|
@ -79,20 +77,20 @@ class DatabaseUserAdminTest(TestCase):
|
|||
def test_save_model_change(self):
|
||||
objmock = Mock()
|
||||
self.dbuadmin.save_model(Mock(name="request"), objmock, Mock(), True)
|
||||
self.assertTrue(objmock.create_in_database.not_called())
|
||||
objmock.create_in_database.assert_not_called()
|
||||
|
||||
def test_save_model_no_change(self):
|
||||
objmock = Mock()
|
||||
self.dbuadmin.save_model(Mock(name="request"), objmock, Mock(), False)
|
||||
self.assertTrue(objmock.create_in_database.called_with())
|
||||
objmock.create_in_database.assert_called_with()
|
||||
|
||||
def test_perform_delete_selected(self):
|
||||
usermock = Mock()
|
||||
selected = Mock()
|
||||
selected.all.return_value = [usermock]
|
||||
self.dbuadmin.perform_delete_selected(Mock(name="request"), selected)
|
||||
self.assertTrue(selected.all.called_with())
|
||||
self.assertTrue(usermock.delete.called_with())
|
||||
selected.all.assert_called_with()
|
||||
usermock.delete.assert_called_with()
|
||||
|
||||
def test_get_actions(self):
|
||||
requestmock = MagicMock(name="request")
|
||||
|
@ -127,20 +125,20 @@ class UserDatabaseAdminTest(TestCase):
|
|||
def test_save_model_change(self):
|
||||
objmock = Mock()
|
||||
self.udbadmin.save_model(Mock(name="request"), objmock, Mock(), True)
|
||||
self.assertTrue(objmock.create_in_database.not_called())
|
||||
objmock.create_in_database.assert_not_called()
|
||||
|
||||
def test_save_model_no_change(self):
|
||||
objmock = Mock()
|
||||
self.udbadmin.save_model(Mock(name="request"), objmock, Mock(), False)
|
||||
self.assertTrue(objmock.create_in_database.called_with())
|
||||
objmock.create_in_database.assert_called_with()
|
||||
|
||||
def test_perform_delete_selected(self):
|
||||
userdbmock = Mock()
|
||||
selected = Mock()
|
||||
selected.all.return_value = [userdbmock]
|
||||
self.udbadmin.perform_delete_selected(Mock(name="request"), selected)
|
||||
self.assertTrue(selected.all.called_with())
|
||||
self.assertTrue(userdbmock.delete.called_with())
|
||||
selected.all.assert_called_with()
|
||||
userdbmock.delete.assert_called_with()
|
||||
|
||||
def test_get_actions(self):
|
||||
requestmock = MagicMock(name="request")
|
||||
|
|
|
@ -82,13 +82,11 @@ class AddUserDatabaseFormTest(TestCase):
|
|||
)
|
||||
form.cleaned_data = {"db_type": DB_TYPES.pgsql, "password1": "secret"}
|
||||
form.save()
|
||||
self.assertTrue(
|
||||
create_userdatabase_with_user.called_with(
|
||||
DB_TYPES.pgsql,
|
||||
self.hostingpackage.osuser,
|
||||
password="secret",
|
||||
commit=True,
|
||||
)
|
||||
create_userdatabase_with_user.assert_called_with(
|
||||
DB_TYPES.pgsql,
|
||||
self.hostingpackage.osuser,
|
||||
password="secret",
|
||||
commit=True,
|
||||
)
|
||||
|
||||
|
||||
|
@ -131,4 +129,4 @@ class ChangeDatabaseUserPasswordFormTest(TestCase):
|
|||
)
|
||||
form.cleaned_data = {"password1": "secret"}
|
||||
form.save()
|
||||
self.assertTrue(instance.set_password.called_with("secret"))
|
||||
instance.set_password.assert_called_with("secret")
|
||||
|
|
914
poetry.lock
generated
914
poetry.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue