def test_inactive_users_are_not_listed(self): user = fixtures.get_user('us-ignite', is_active=False) fixtures.get_profile(user=user, name='us ignite') response = views.profile_list(self._get_request()) eq_(response.status_code, 200) eq_(len(response.context_data['page'].object_list), 0) _teardown_profiles()
def test_people_page_detail_is_successful(self): user = fixtures.get_user('us-ignite') fixtures.get_profile(user=user, name='us ignite', slug='ignite') self.client.login(username='******', password='******') response = self.client.get('/people/ignite/') eq_(response.status_code, 200) self.client.logout() _teardown_profiles()
def test_export_shows_active_users(self): url = '/admin/profiles/profile/export/' user = fixtures.get_user( 'john', email='*****@*****.**', first_name='John Donne') fixtures.get_profile(user=user) response = self.client.post(url, {}) eq_(response.status_code, 200) ok_('attachment;' in response['Content-Disposition']) eq_(response.content, 'John Donne,[email protected]\r\n')
def test_users_can_be_reverse_sorted(self): user_a = fixtures.get_user('alpha') profile_a = fixtures.get_profile(user=user_a, name='alpha') user_b = fixtures.get_user('beta') profile_b = fixtures.get_profile(user=user_b, name='beta') request = self._get_request(data={'order': '-user__first_name'}) response = views.profile_list(request) eq_(list(response.context_data['page'].object_list), [profile_b, profile_a]) _teardown_profiles()
def test_form_filter_users_by_end_date(self): url = '/admin/profiles/profile/export/' user = fixtures.get_user('john', email='*****@*****.**') created = datetime(2013, 12, 6, 0, 0, 0).replace(tzinfo=utc) fixtures.get_profile(user=user, name='John Donne', created=created) response = self.client.post( url, {'end_0': '2013-12-5', 'end_1': '00:00:00'}) eq_(response.status_code, 200) messages = [m.message for m in list(response.context['messages'])] eq_(messages, ['No users registered during the given dates.'])
def test_get_request_is_successful(self): user = fixtures.get_user('us-ignite') fixtures.get_profile(user=user, slug='someone', name='us ignite') response = views.profile_detail(self._get_request(), 'someone') ok_(response.status_code, 200) eq_(sorted(response.context_data.keys()), sorted(['object', 'application_list', 'event_list', 'resource_list', 'hub_list', 'hub_request_list', 'organization_list', 'award_list', 'is_owner'])) _teardown_profiles()
def test_form_filter_uses_end_and_start_date(self): url = '/admin/profiles/profile/export/' user = fixtures.get_user( 'john', email='*****@*****.**', first_name='John Donne') created = datetime(2013, 12, 6).replace(tzinfo=utc) fixtures.get_profile(user=user, created=created) response = self.client.post(url, { 'start_0': '2013-12-5', 'start_1': '00:00:00', 'end_0': '2013-12-7', 'end_1': '23:59:59', }) eq_(response.status_code, 200) eq_(response.status_code, 200) ok_('attachment;' in response['Content-Disposition']) eq_(response.content, 'John Donne,[email protected]\r\n')
def test_create_basic_link_is_successful(self): user = fixtures.get_user('foo') profile = fixtures.get_profile(user=user) data = { 'profile': profile, 'url': 'http://us-ignite.org/', } link = ProfileLink.objects.create(**data) ok_(link.id)
def test_profile_link_absolute_is_external_url(self): user = fixtures.get_user('foo') profile = fixtures.get_profile(user=user) data = { 'profile': profile, 'url': 'http://us-ignite.org/b/', } link = ProfileLink.objects.create(**data) eq_(link.url, 'http://us-ignite.org/b/')
def test_gravatar_url_exists(self): user = fixtures.get_user('paul') profile = fixtures.get_profile(user=user) eq_(profile.get_gravatar_url(), '//www.gravatar.com/avatar/f978b2b03ad48da6d36c431f72d6fd97?s=276')
def test_empty_profile_user_display_name_is_valid(self): user = fixtures.get_user('john', first_name='US Ignite user') profile = fixtures.get_profile(user=user) eq_(profile.display_name, u'US Ignite user')
def test_display_email(self): user = fixtures.get_user('john', email='*****@*****.**') profile = fixtures.get_profile(user=user, name='john') eq_(profile.display_email, u'john <*****@*****.**>')
def test_people_page_detail_requires_auth(self): user = fixtures.get_user('us-ignite') fixtures.get_profile(user=user, name='us ignite', slug='ignite') response = self.client.get('/people/ignite/') assert_redirects(response, utils.get_login_url('/people/ignite/')) _teardown_profiles()
def test_get_contact_url(self): user = fixtures.get_user('john', email='*****@*****.**') profile = fixtures.get_profile(user=user, name='john', slug='john') eq_(profile.get_contact_url(), u'/contact/john/')
def test_user_is_owner(self): user = fixtures.get_user('john', email='*****@*****.**') profile = fixtures.get_profile(user=user, name='john', slug='john') eq_(profile.is_owned_by(user), True)
def test_user_display_name_is_valid(self): user = fixtures.get_user('john', first_name='John Donne') profile = fixtures.get_profile(user=user) eq_(profile.display_name, u'John Donne')
def test_anon_user_is_not_owner(self): user = fixtures.get_user('john', email='*****@*****.**') profile = fixtures.get_profile(user=user, name='john', slug='john') eq_(profile.is_owned_by(utils.get_anon_mock()), False)