class TestDisableUser(AdminTestCase): def setUp(self): self.user = UserFactory() self.request = RequestFactory().post('/fake_path') self.view = UserDeleteView() self.view = setup_log_view(self.view, self.request, guid=self.user._id) def test_get_object(self): obj = self.view.get_object() nt.assert_is_instance(obj, User) def test_get_context(self): res = self.view.get_context_data(object=self.user) nt.assert_in('guid', res) nt.assert_equal(res.get('guid'), self.user._id) def test_disable_user(self): settings.ENABLE_EMAIL_SUBSCRIPTIONS = False count = OSFLogEntry.objects.count() self.view.delete(self.request) self.user.reload() nt.assert_true(self.user.is_disabled) nt.assert_equal(OSFLogEntry.objects.count(), count + 1) def test_reactivate_user(self): settings.ENABLE_EMAIL_SUBSCRIPTIONS = False self.view.delete(self.request) count = OSFLogEntry.objects.count() self.view.delete(self.request) self.user.reload() nt.assert_false(self.user.is_disabled) nt.assert_equal(OSFLogEntry.objects.count(), count + 1)
def setUp(self): self.user = UserFactory() self.request = RequestFactory().post('/fake_path') self.view = UserDeleteView() self.view = setup_log_view(self.view, self.request, guid=self.user._id)
def test_no_user(self): view = setup_view(UserDeleteView(), self.request, guid='meh') with nt.assert_raises(Http404): view.delete(self.request)