Beispiel #1
0
 def test_auto_unique_slug(self):
     name = 'Mile High Connects'
     organization = create_organization(name=name)
     self.assertEqual(organization.slug, "mile-high-connects")
     organization2 = create_organization(name=name)
     self.assertEqual(organization2.slug, "mile-high-connects-2")
     self.assertEqual(Organization.objects.filter(
         slug="mile-high-connects").count(), 1)
Beispiel #2
0
    def test_user_can_view(self):
        org = create_organization(name="Test Organization", 
                status='pending')
        OrganizationMembership.objects.create(user=self.user1, organization=org,
                member_type='owner')

        # Test owner cannot view their own pending organization
        self.assertFalse(org.user_can_view(self.user1))

        # Test non-owner cannot view a pending organization
        self.assertFalse(org.user_can_view(self.user2))

        # Test an admin user can view another user's pending organization
        self.assertTrue(org.user_can_view(self.admin_user))

        # Test that a super user can view another user's pending organization 
        self.assertTrue(org.user_can_view(self.superuser))

        # Publish the organization to set up for next tests
        org.status = 'published'
        org.save()
        
        # Test that owner can view a published organization 
        self.assertTrue(org.user_can_view(self.user1))

        # Test that another user can view a published organization 
        self.assertTrue(org.user_can_view(self.user2))
Beispiel #3
0
 def test_owners(self):
     org = create_organization(name='Mile High Connects',
             status='published')
     user1 = User.objects.create_user("test", "*****@*****.**", "test")
     user2 = User.objects.create_user("test2", "*****@*****.**", "test2")
     OrganizationMembership.objects.create(user=user1, organization=org,
             member_type='owner')
     OrganizationMembership.objects.create(user=user2, organization=org,
             member_type='member')
     self.assertIn(user1, org.owners)
     self.assertNotIn(user2, org.owners)
Beispiel #4
0
    def test_anonymoususer_can_view(self):
        org = create_organization(name="Test Organization", 
                status='pending')

        # An anonymous user can't view a pending organization
        self.assertFalse(org.anonymoususer_can_view(self.anonymous_user))

        org.status = 'published'
        org.save()

        # An anonymous user can view a published organization
        self.assertTrue(org.anonymoususer_can_view(self.anonymous_user))
Beispiel #5
0
 def test_ordered_stories_by_weight(self):
     """ Tests that ordered_stories will order first by weight """
     organization = create_organization(name='Mile High Connects')
     story1 = create_story(title='Story 1', summary='', byline='')
     story2 = create_story(title='Story 2', summary='', byline='')
     organization.add_story(story1, 5)
     sleep(2)
     organization.add_story(story2, 25)
     stories = organization.ordered_stories()
     self.assertEqual(stories.count(), 2)
     self.assertEqual(stories[0], story1)
     self.assertEqual(stories[1], story2)
Beispiel #6
0
    def test_create_organization(self):

        name = "Mile High Connects"
        website_url = "http://www.urbanlandc.org/collaboratives/mile-high-connects/"
        description = 'Mile High Connects (formerly know as the Mile High Transit Opportunity Collaborative) is an emerging collaborative of nonprofit and philanthropic organizations working together to ensure the creation of the region\'s $6.7 billion FasTracks transit system benefits all communities in the region, including low-income populations.'
        with self.assertRaises(Organization.DoesNotExist):
            Organization.objects.get(organizationtranslation__name=name)
        org = create_organization(name=name, description=description, website_url=website_url)
        self.assertEqual(org.name, name)
        self.assertEqual(org.description, description)
        self.assertEqual(org.website_url, website_url)
        retrieved_org = Organization.objects.get(pk=org.pk)
        self.assertEqual(retrieved_org.name, name)
        self.assertEqual(retrieved_org.description, description)
        self.assertEqual(retrieved_org.website_url, website_url)
Beispiel #7
0
 def test_add_story(self):
     organization = create_organization(name='Mile High Connects')
     title = "Transportation Challenges Limit Education Choices for Denver Parents"
     summary = """
         Many families in the Denver metro area use public
         transportation instead of a school bus because for them, a
         quality education is worth hours of daily commuting. Colorado's
         school choice program is meant to foster educational equity,
         but the families who benefit most are those who have time and
         money to travel. Low-income families are often left in a lurch.
         """
     byline = "Mile High Connects"
     story = create_story(title=title, summary=summary, byline=byline)
     weight = 15
     organization.add_story(story, weight) 
     self.assertTrue(story in organization.curated_stories.all())
     OrganizationStory.objects.get(organization=organization, story=story,
                              weight=weight)
Beispiel #8
0
 def test_update(self):
     org = create_organization(name="Test Organization", 
             description="Test organization description",
             website_url="http://example.com/")
     data = {
         'name': 'Test Organization 2',
         'description': 'Test organization description 2',
         'website_url': 'http://example.com/2/',
     }
     f = OrganizationModelForm(data, instance=org)
     f.save()
     self.assertEqual(org.name, data['name'])
     self.assertEqual(org.description, data['description'])
     self.assertEqual(org.website_url, data['website_url'])
     # Check that the changes were saved to the database
     org = Organization.objects.get(pk=org.pk)
     self.assertEqual(org.name, data['name'])
     self.assertEqual(org.description, data['description'])
     self.assertEqual(org.website_url, data['website_url'])
Beispiel #9
0
    def test_send_approval_notification_org(self):
        """Test the send_notifications_signal"""
        backend = getattr(settings, 'EMAIL_BACKEND', None)
        if backend != 'django.core.mail.backends.locmem.EmailBackend':
            self.fail("You must use the in-memory e-mail backend when "
                      "running this test")

        org = create_organization("Test Organization", status="pending")
        OrganizationMembership.objects.create(organization=org,
                user=self.user, member_type='owner')
        org.status = 'published'
        send_approval_notification(Organization, org, False)

        from django.core.mail import outbox
        sent_email = outbox[0]
        self.assertIn(self.user.email, sent_email.to)
        self.assertIn(org.name, sent_email.subject)
        self.assertIn(org.name, sent_email.body)
        self.assertIn(org.get_absolute_url(), sent_email.body)
Beispiel #10
0
def organizations_in_database(step):
    for organization_dict in step.hashes:
        create_organization(**organization_dict)
Beispiel #11
0
def organization_created(step, name):
    try:
        Organization.objects.get(organizationtranslation__name=name)
    except Organization.DoesNotExist:
        create_organization(name)
Beispiel #12
0
 def setup_organization(self):
     self.organization = create_organization("Test Organization",
                                             status='published')
Beispiel #13
0
 def create_model(self, name):
     return create_organization(name=name, status="pending")
Beispiel #14
0
def organization_created(step, name):
    try:
        Organization.objects.get(organizationtranslation__name=name)
    except Organization.DoesNotExist:
        create_organization(name)
Beispiel #15
0
def organization_created(step, name):
    create_organization(name)
def setup_organization_and_project(scenario):
    matching_scenarios = ('An admin can create a story and it\'s core metadata in English')
    if scenario.name in matching_scenarios: 
        create_organization(name="Mile High Connects") 
        create_project(name='The Metro Denver Regional Equity Atlas')
Beispiel #17
0
def setup_organization(scenario):
    matching_scenarios = ('Admin can create a new Project', )
    if scenario.name in matching_scenarios:
        create_organization("Mile High Connects")
Beispiel #18
0
def organizations_in_database(step):
    for organization_dict in step.hashes:
        create_organization(**organization_dict)
Beispiel #19
0
def setup_organization_and_project(scenario):
    matching_scenarios = (
        'An admin can create a story and it\'s core metadata in English')
    if scenario.name in matching_scenarios:
        create_organization(name="Mile High Connects")
        create_project(name='The Metro Denver Regional Equity Atlas')
Beispiel #20
0
def setup_organization(scenario):
    matching_scenarios = ('Admin can create a new Project',)
    if scenario.name in matching_scenarios: 
        create_organization("Mile High Connects") 
Beispiel #21
0
def organization_created(step, name):
    create_organization(name)