Ejemplo n.º 1
0
    def setUp(self):
        self.baseURL = 'http://*****:*****@test.com');
        self.user.set_password('1234');
        self.user.save();

        self.org1 = Organization(name='test org 1', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=1));
        self.org2 = Organization(name='test org 2', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=2));
        self.org3 = Organization(name='test org 3', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=1));
        
        self.org1.save();
        self.org2.save();
        self.org3.save();

        self.event1 = Event(name='test 1', contact_email='*****@*****.**', organization=self.org1, start_time=timezone.now(), end_time=timezone.now());
        self.event2 = Event(name='test 2', contact_email='*****@*****.**', organization=self.org2, start_time=timezone.now(), end_time=timezone.now());
        self.event3 = Event(name='test 3', contact_email='*****@*****.**', organization=self.org3, start_time=timezone.now(), end_time=timezone.now());

        self.event1.save();
        self.event2.save();
        self.event3.save();

        self.uto1 = UserToOrganization(user=self.user, organization=self.org1);
        self.uto2 = UserToOrganization(user=self.user, organization=self.org2);
        self.uto3 = UserToOrganization(user=self.user, organization=self.org3);

        self.ute1 = UserToEvent(user=self.user, event=self.event1);
        self.ute2 = UserToEvent(user=self.user, event=self.event2);
        self.ute3 = UserToEvent(user=self.user, event=self.event3);

        self.client.login(username='******', password='******');
Ejemplo n.º 2
0
 def testEventUnubscribeWhenNotSubscribed(self):
     try:
         with transaction.atomic():
             self.client.post(self.baseURL + '/events/unsubscribe', {'event_id': 2});
     except ObjectDoesNotExist:
         pass;
     
     self.assertFalse(UserToEvent.userSubscribedToEvent(user=self.user, event=self.event_2));
Ejemplo n.º 3
0
    def testEventSubscribeMoreThanOnce(self):
        self.client.post(self.baseURL + '/events/subscribe', {'event_id': 2});

        try:
            with transaction.atomic():
                self.client.post(self.baseURL + '/events/subscribe', {'event_id': 2});
        except IntegrityError:
            pass;

        self.assertTrue(UserToEvent.userSubscribedToEvent(user=self.user, event=self.event_2));
Ejemplo n.º 4
0
    def testAddValidUserToEventMapping_GetEventsForUser(self):
        UserToEvent(user=self.user, event=self.event, admin=True).save();
        UserToEvent(user=self.user, event=self.event2).save();
        UserToEvent(user=self.user, event=self.event3, admin=True).save();

        ute = UserToEvent.getEventsForUser(self.user);
        event_result1 = ute[0];
        event_result2 = ute[1];
        event_result3 = ute[2];

        self.assertTrue(event_result1 == self.event);
        self.assertTrue(event_result2 == self.event2);
        self.assertTrue(event_result3 == self.event3);
Ejemplo n.º 5
0
    def testEventUnsubscribe(self):
        self.client.post(self.baseURL + '/events/unsubscribe', {'event_id': 1});

        self.assertFalse(UserToEvent.userSubscribedToEvent(user=self.user, event=self.event_1));
Ejemplo n.º 6
0
    def testEventSubscribe(self):
        self.client.post(self.baseURL + '/events/subscribe', {'event_id': 2});

        self.assertTrue(UserToEvent.userSubscribedToEvent(user=self.user, event=self.event_2));
Ejemplo n.º 7
0
class UserDashboardTests(TestCase):

    client = Client();

    def setUp(self):
        self.baseURL = 'http://*****:*****@test.com');
        self.user.set_password('1234');
        self.user.save();

        self.org1 = Organization(name='test org 1', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=1));
        self.org2 = Organization(name='test org 2', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=2));
        self.org3 = Organization(name='test org 3', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=1));
        
        self.org1.save();
        self.org2.save();
        self.org3.save();

        self.event1 = Event(name='test 1', contact_email='*****@*****.**', organization=self.org1, start_time=timezone.now(), end_time=timezone.now());
        self.event2 = Event(name='test 2', contact_email='*****@*****.**', organization=self.org2, start_time=timezone.now(), end_time=timezone.now());
        self.event3 = Event(name='test 3', contact_email='*****@*****.**', organization=self.org3, start_time=timezone.now(), end_time=timezone.now());

        self.event1.save();
        self.event2.save();
        self.event3.save();

        self.uto1 = UserToOrganization(user=self.user, organization=self.org1);
        self.uto2 = UserToOrganization(user=self.user, organization=self.org2);
        self.uto3 = UserToOrganization(user=self.user, organization=self.org3);

        self.ute1 = UserToEvent(user=self.user, event=self.event1);
        self.ute2 = UserToEvent(user=self.user, event=self.event2);
        self.ute3 = UserToEvent(user=self.user, event=self.event3);

        self.client.login(username='******', password='******');

    def tearDown(self):
        self.client.logout();

    def testValidDashboard_ShowClubEvents(self):
        self.uto1.save();
        self.uto2.save();
        self.uto3.save();

        response = self.client.get(self.baseURL + '/user');

        self.assertTrue(self.event1.name in response.content);
        self.assertTrue('test 1' in response.content);
        self.assertTrue('test 2' in response.content);
        self.assertTrue('test 3' in response.content);

    def testValidDashboard_ShowSubscribedEvents(self):
        self.ute1.save();
        self.ute2.save();
        self.ute3.save();

        response = self.client.get(self.baseURL + '/user');

        self.assertTrue('test 1' in response.content);
        self.assertTrue('test 2' in response.content);
        self.assertTrue('test 3' in response.content);

    def testValidDashboard_ShowTwoSubscribedEvents(self):
        self.ute1.save();
        self.ute2.save();

        response = self.client.get(self.baseURL + '/user');

        self.assertTrue('test 1' in response.content);
        self.assertTrue('test 2' in response.content);

    def testValidDashboard_ShowOneSubscribedEvents(self):
        self.ute1.save();

        response = self.client.get(self.baseURL + '/user');

        self.assertTrue('test 1' in response.content);
Ejemplo n.º 8
0
class UserProfileTests(TestCase):

    client = Client();

    def setUp(self):
        self.baseURL = 'http://*****:*****@test.com');
        self.user.set_password('1234');
        self.user.save();

        self.org1 = Organization(name='test org 1', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=1));
        self.org2 = Organization(name='test org 2', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=2));
        self.org3 = Organization(name='test org 3', contact_email='*****@*****.**', organization_type=OrganizationType.objects.get(id=1));
        
        self.org1.save();
        self.org2.save();
        self.org3.save();

        self.event1 = Event(name='test 1', contact_email='*****@*****.**', organization=self.org1, start_time=timezone.now(), end_time=timezone.now());
        self.event2 = Event(name='test 2', contact_email='*****@*****.**', organization=self.org2, start_time=timezone.now(), end_time=timezone.now());
        self.event3 = Event(name='test 3', contact_email='*****@*****.**', organization=self.org3, start_time=timezone.now(), end_time=timezone.now());

        self.event1.save();
        self.event2.save();
        self.event3.save();

        self.uto1 = UserToOrganization(user=self.user, organization=self.org1);
        self.uto2 = UserToOrganization(user=self.user, organization=self.org2);
        self.uto3 = UserToOrganization(user=self.user, organization=self.org3);

        self.ute1 = UserToEvent(user=self.user, event=self.event1);
        self.ute2 = UserToEvent(user=self.user, event=self.event2);
        self.ute3 = UserToEvent(user=self.user, event=self.event3);

        self.client.login(username='******', password='******');

    def tearDown(self):
        self.client.logout();

    def testValidProfile_OneEvent(self):
        self.ute1.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.event1.name in response.content);
        self.assertTrue('href="/events/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.event2.name not in response.content);
        self.assertTrue('href="/events/2"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

        self.assertTrue(self.event3.name not in response.content);
        self.assertTrue('href="/events/3"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

    def testValidProfile_TwoEvents1(self):
        self.ute1.save();
        self.ute2.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.event1.name in response.content);
        self.assertTrue('href="/events/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.event2.name in response.content);
        self.assertTrue('href="/events/2"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.event3.name not in response.content);
        self.assertTrue('href="/events/3"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

    def testValidProfile_TwoEvents2(self):
        self.ute1.save();
        self.ute3.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.event1.name in response.content);
        self.assertTrue('href="/events/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.event2.name not in response.content);
        self.assertTrue('href="/events/2"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

        self.assertTrue(self.event3.name in response.content);
        self.assertTrue('href="/events/3"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

    def testValidProfile_ThreeEvents(self):
        self.ute1.save();
        self.ute2.save();
        self.ute3.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.event1.name in response.content);
        self.assertTrue('href="/events/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.event2.name in response.content);
        self.assertTrue('href="/events/2"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.event3.name in response.content);
        self.assertTrue('href="/events/3"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

    def testValidProfile_OneOrg(self):
        self.uto1.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.org1.name in response.content);
        self.assertTrue('href="/clubs/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.org2.name not in response.content);
        self.assertTrue('href="/clubs/2"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

        self.assertTrue(self.org3.name not in response.content);
        self.assertTrue('href="/clubs/3"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

    def testValidProfile_TwoOrgs1(self):
        self.uto1.save();
        self.uto2.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.org1.name in response.content);
        self.assertTrue('href="/clubs/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.org2.name in response.content);
        self.assertTrue('href="/clubs/2"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.org3.name not in response.content);
        self.assertTrue('href="/clubs/3"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

    def testValidProfile_TwoOrgs2(self):
        self.uto1.save();
        self.uto3.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.org1.name in response.content);
        self.assertTrue('href="/clubs/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.org2.name not in response.content);
        self.assertTrue('href="/clubs/2"' not in response.content);
        self.assertTrue('href="mailto:[email protected]"' not in response.content);

        self.assertTrue(self.org3.name in response.content);
        self.assertTrue('href="/clubs/3"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

    def testValidProfile_ThreeOrgs(self):
        self.uto1.save();
        self.uto2.save();
        self.uto3.save();

        response = self.client.get(self.baseURL + '/user/%d' % self.user.id);

        self.assertTrue(self.org1.name in response.content);
        self.assertTrue('href="/clubs/1"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.org2.name in response.content);
        self.assertTrue('href="/clubs/2"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);

        self.assertTrue(self.org3.name in response.content);
        self.assertTrue('href="/clubs/3"' in response.content);
        self.assertTrue('href="mailto:[email protected]"' in response.content);