class SuperUserTest(OrgaBasicTest): def setUp(self): super(SuperUserTest, self).setUp() self.client = SuperUserAuthClient() self.expected_code = 200 self.expected_save_code = 403 self.expect_templates = True self.orgas = [ OrganizationFactory(address_canton=c) for c in DV_STATES] def test_autocompletes(self): for al in ['OrganizationAutocomplete']: url = reverse( 'autocomplete_light_autocomplete', kwargs={'autocomplete': al} ) response = self.client.get(url) self.assertEqual(response.status_code, self.expected_code, url) # Check that we only find our orga entries = [int(d) for d in re.findall('data-value="(\d+)"', str(response.content)) ] entries.sort() self.assertEqual( entries, [self.orga.pk] + [o.pk for o in self.orgas] )
def setUp(self): super(SuperUserTest, self).setUp() self.client = SuperUserAuthClient() self.expected_code = 200 self.expected_save_code = 403 self.expect_templates = True self.orgas = [ OrganizationFactory(address_canton=c) for c in DV_STATES]
class SuperUserTest(ProfileTestCase): def setUp(self): super(SuperUserTest, self).setUp() self.client = SuperUserAuthClient() def test_send_creds(self): nmails = 0 for otheruser in self.users: url = tryurl("user-sendcredentials", otheruser) response = self.client.get(url) self.assertEqual(response.status_code, 200, url) # Now post to it, to get the mail sent response = self.client.post(url, {}) self.assertEqual(response.status_code, 302, url) nmails += 1 self.assertEqual(len(mail.outbox), nmails) # Verify what they are from the DB dbuser = get_user_model().objects.get(pk=otheruser.pk) self.assertTrue(dbuser.is_active) self.assertTrue(dbuser.has_usable_password()) self.assertTrue(dbuser.profile.can_login) # Second try should fail, now that each of the users has a # a valid email and got a password sent response = self.client.get(url) self.assertEqual(response.status_code, 403, url) # Allowed to re-send creds though, any number of times for i in range(2): url = tryurl("user-resendcredentials", otheruser) response = self.client.get(url) self.assertEqual(response.status_code, 200, url) response = self.client.post(url, {}) self.assertEqual(response.status_code, 302, url) nmails += 1 self.assertEqual(len(mail.outbox), nmails)
def setUp(self): super(SuperUserTest, self).setUp() self.client = SuperUserAuthClient()