Exemple #1
0
 def test_published_hub_request_is_successful(self):
     fixtures.get_hub(name='community', status=models.Hub.PUBLISHED)
     request = utils.get_request(
         'get', '/hub/community/', user=utils.get_anon_mock())
     response = views.hub_detail(request, 'community')
     eq_(response.status_code, 200)
     eq_(sorted(response.context_data.keys()),
         sorted(['object', 'feature_list', 'member_list', 'is_member',
                 'is_contact', 'activity_list', 'event_list', 'award_list'])
     )
Exemple #2
0
 def test_membership_request_is_successful(self):
     member = get_user('member')
     hub = fixtures.get_hub(name='community', status=models.Hub.PUBLISHED)
     request = utils.get_request(
         'post', '/hub/community/', data={}, user=member)
     request._messages = utils.TestMessagesBackend(request)
     response = views.hub_membership(request, 'community')
     eq_(response.status_code, 302)
     eq_(response['Location'], hub.get_absolute_url())
     ok_(models.HubMembership.objects.get(user=member, hub=hub))
Exemple #3
0
 def test_contact_request_is_successful(self):
     contact = get_user('contact')
     hub = fixtures.get_hub(
         name='community', status=models.Hub.PUBLISHED, contact=contact)
     request = utils.get_request(
         'get', '/hub/community/edit/', user=contact)
     response = views.hub_edit(request, 'community')
     eq_(response.status_code, 200)
     eq_(response.template_name, 'hubs/object_edit.html')
     eq_(sorted(response.context_data.keys()), sorted(['form', 'object']))
     eq_(response.context_data['object'], hub)
Exemple #4
0
 def test_contact_unpublished_request_succeeds(self):
     contact = get_user('contact')
     hub = fixtures.get_hub(name='community', status=models.Hub.DRAFT,
                            contact=contact)
     request = utils.get_request('get', '/hub/community/', user=contact)
     response = views.hub_detail(request, 'community')
     eq_(response.status_code, 200)
     eq_(sorted(response.context_data.keys()),
         sorted(['object', 'feature_list', 'member_list', 'is_member',
                 'is_contact', 'activity_list', 'event_list', 'award_list'])
     )
Exemple #5
0
 def test_create_membership(self):
     user = get_user('member')
     hub = fixtures.get_hub(status=Hub.PUBLISHED)
     data = {
         'hub': hub,
         'user': user,
     }
     instance = HubMembership.objects.create(**data)
     ok_(instance.id)
     eq_(instance.hub, hub)
     eq_(instance.user, user)
     ok_(instance.created)
Exemple #6
0
 def test_hub_award_creation_is_successful(self):
     user = get_user('us-ignite')
     hub = get_hub()
     award = fixtures.get_award(name='Gold star')
     data = {
         'hub': hub,
         'award': award,
     }
     instance = HubAward.objects.create(**data)
     ok_(instance.id)
     ok_(instance.created)
     eq_(instance.hub, hub)
     eq_(instance.award, award)
Exemple #7
0
 def test_hub_url_creation(self):
     contact = get_user('contact')
     hub = fixtures.get_hub(contact=contact)
     data = {
         'hub': hub,
         'name': 'URL',
         'url': 'https://us-ignite.org',
     }
     instance = HubURL.objects.create(**data)
     ok_(instance.id)
     eq_(instance.hub, hub)
     eq_(instance.name, 'URL')
     eq_(instance.url, 'https://us-ignite.org')
Exemple #8
0
 def test_membership_is_create_successful(self):
     user = get_user('owner')
     hub = fixtures.get_hub(name='Gigabit hub')
     app = get_application(owner=user)
     data = {
         'hub': hub,
         'application': app,
     }
     instance = HubAppMembership.objects.create(**data)
     ok_(instance.id)
     eq_(instance.hub, hub)
     eq_(instance.application, app)
     eq_(instance.is_featured, False)
     ok_(instance.created)
Exemple #9
0
 def test_contact_update_is_successful(self):
     contact = get_user('contact')
     hub = fixtures.get_hub(
         name='community', status=models.Hub.PUBLISHED, contact=contact)
     data = {
         'name': 'New name!',
         'description': 'New description.'
     }
     request = utils.get_request(
         'post', '/hub/community/edit/', data=data, user=contact)
     request._messages = utils.TestMessagesBackend(request)
     response = views.hub_edit(request, 'community')
     eq_(response.status_code, 302)
     eq_(response['Location'], hub.get_absolute_url())
     eq_(models.Hub.objects.values('name').get(slug='community'),
         {'name': 'New name!'})
Exemple #10
0
 def test_featured_hub_is_returned(self):
     hub = fixtures.get_hub(status=Hub.PUBLISHED, is_featured=True)
     eq_(Hub.active.get_featured(), hub)
Exemple #11
0
 def test_record_activity_is_successful(self, mock_create):
     contact = get_user('contact')
     instance = fixtures.get_hub(contact=contact)
     instance.record_activity('Hello')
     mock_create.assert_called_once_with(hub=instance, name='Hello')
Exemple #12
0
 def test_get_membership_url(self):
     contact = get_user('contact')
     instance = fixtures.get_hub(contact=contact)
     eq_(instance.get_membership_url(), '/hub/%s/membership/' % instance.slug)
Exemple #13
0
 def test_get_absolute_url(self):
     contact = get_user('contact')
     instance = fixtures.get_hub(contact=contact)
     eq_(instance.get_absolute_url(), '/hub/%s/' % instance.slug)
Exemple #14
0
 def test_unpublished_hub_is_visible_to_contact(self):
     contact = get_user('contact')
     instance = fixtures.get_hub(contact=contact, status=Hub.DRAFT)
     eq_(instance.is_visible_by(contact), True)
Exemple #15
0
 def test_unpublished_hubs_are_not_listed(self):
     hub = fixtures.get_hub(name='gigabit', status=Hub.DRAFT)
     eq_(list(Hub.active.all()), [])
Exemple #16
0
 def test_is_draft(self):
     contact = get_user('contact')
     instance = fixtures.get_hub(contact=contact, status=Hub.DRAFT)
     eq_(instance.is_draft(), True)
Exemple #17
0
 def test_is_contact(self):
     contact = get_user('contact')
     instance = fixtures.get_hub(contact=contact)
     eq_(instance.is_contact(contact), True)
Exemple #18
0
 def test_unpublished_hub_request_fails(self):
     fixtures.get_hub(name='community', status=models.Hub.DRAFT)
     request = utils.get_request(
         'get', '/hub/community/', user=utils.get_anon_mock())
     views.hub_detail(request, 'community')
Exemple #19
0
 def test_not_featured_hub_returns_none(self):
     hub = fixtures.get_hub(status=Hub.PUBLISHED, is_featured=False)
     eq_(Hub.active.get_featured(), None)
Exemple #20
0
 def test_not_contact_request_fails(self):
     user = get_user('us-ignite')
     fixtures.get_hub(name='community', status=models.Hub.PUBLISHED)
     request = utils.get_request('get', '/hub/community/edit/', user=user)
     views.hub_edit(request, 'community')
Exemple #21
0
 def test_is_published(self):
     contact = get_user('contact')
     instance = fixtures.get_hub(contact=contact, status=Hub.PUBLISHED)
     eq_(instance.is_published(), True)
Exemple #22
0
 def setUp(self):
     self.factory = client.RequestFactory()
     self.hub = get_hub(name='My hub.', status=Hub.PUBLISHED)
     self.user = get_user('us-ignite')
Exemple #23
0
 def test_published_hub_is_visible(self):
     instance = fixtures.get_hub(status=Hub.PUBLISHED)
     eq_(instance.is_visible_by(utils.get_anon_mock()), True)
Exemple #24
0
 def test_published_hubs_are_listed(self):
     hub = fixtures.get_hub(name='gigabit', status=Hub.PUBLISHED)
     eq_(list(Hub.active.all()), [hub])