def test_delete_user(self, mocked_task): staff = structure_factories.UserFactory(is_staff=True) self.client.force_authenticate(staff) self.client.delete(structure_factories.UserFactory.get_url(self.owner)) self.assert_task_called(mocked_task, 'nodeconductor.structure.remove_user', serialize_user(self.owner))
def test_grant_and_revoke_user_from_project(self, mocked_task): user = structure_factories.UserFactory() ssh_key = structure_factories.SshPublicKeyFactory(user=user) # Grant user in project self.project.add_user(user, ProjectRole.ADMINISTRATOR) self.assert_task_called(mocked_task, 'nodeconductor.structure.push_ssh_public_key', ssh_key.uuid.hex) self.assert_task_called(mocked_task, 'nodeconductor.structure.add_user', user.uuid.hex) # Revoke user in project self.project.remove_user(user) self.assert_task_called( mocked_task, 'nodeconductor.structure.remove_ssh_public_key', serialize_ssh_key(ssh_key)) self.assert_task_called(mocked_task, 'nodeconductor.structure.remove_user', serialize_user(user))
def remove_user(self, user): send_task('structure', 'remove_user')(serialize_user(user), self.link)
def test_remove_user_skips_if_link_is_gone(self, mock_backend): self.link.delete() structure_tasks.remove_user(serialize_user(self.user), self.link_str) self.assertFalse(mock_backend().remove_user.called)
def test_remove_user_calls_backend(self, mock_backend): structure_tasks.remove_user(serialize_user(self.user), self.link_str) self.assertTrue(mock_backend().remove_user.called)