Exemplo n.º 1
0
    def test_empty_event_is_not_full(self):
        mission = Mission(title="Test Mission")
        mission.save()

        event = Event(title="Test Event", min_people=0, max_people=1, start_date=timezone.now(), mission=mission)
        event.save()

        self.assertFalse(event.is_full())
Exemplo n.º 2
0
    def test_event_with_min_people_can_start(self):
        user = User()
        user.save()

        mission = Mission(title="Test Mission")
        mission.save()

        event = Event(title="Test Event", min_people=1, max_people=3, start_date=timezone.now(), mission=mission)
        event.save()

        pledge = Pledge(event=event, user=user, timestamp=timezone.now())
        pledge.save()

        self.assertTrue(event.can_start())
Exemplo n.º 3
0
    def test_event_with_one_canceled_pledge_has_no_active(self):
        user = User()
        user.save()

        mission = Mission(title="Test Mission")
        mission.save()

        event = Event(title="Test Event", min_people=0, max_people=1, start_date=timezone.now(), mission=mission)
        event.save()

        pledge = Pledge(event=event, user=user, timestamp=timezone.now(), cancel_timestamp=timezone.now())
        pledge.save()

        self.assertEquals(len(event.active_pledges()), 0)
Exemplo n.º 4
0
    def test_full_event_is_not_full(self):
        user = User()
        user.save()

        mission = Mission(title="Test Mission")
        mission.save()

        event = Event(title="Test Event", min_people=0, max_people=1, start_date=timezone.now(), mission=mission)
        event.save()

        pledge = Pledge(event=event, user=user, timestamp=timezone.now())
        pledge.save()

        self.assertTrue(event.is_full())
Exemplo n.º 5
0
    def test_pledged_user_has_active_pledge(self):
        user = User()
        user.save()

        mission = Mission(title="Test Mission")
        mission.save()

        event = Event(title="Test Event", min_people=0, max_people=1, start_date=timezone.now(), mission=mission)
        event.save()

        canceled_pledge = Pledge(event=event, user=user, timestamp=timezone.now())
        canceled_pledge.save()

        pledge = Pledge(event=event, user=user, timestamp=timezone.now())
        pledge.save()

        self.assertTrue(event.user_has_active_pledge(user))
Exemplo n.º 6
0
    def test_pledge_can_be_canceled(self):
        User.objects.create_user(username='******', password='******')

        mission = Mission(title='Test Mission')
        mission.save()

        event = Event(title='Test Event',
                      min_people=1,
                      max_people=3,
                      start_date=timezone.now(),
                      mission=mission)
        event.save()

        self.assertEquals(len(event.active_pledges()), 0)

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

        response = client.post('/pledge', {'event-id': event.id})
        self.assertEquals(response.status_code, 302)

        self.assertEquals(len(event.active_pledges()), 1)

        response = client.post('/cancel_pledge', {'event-id': event.id})
        self.assertEquals(response.status_code, 302)

        self.assertEquals(len(event.active_pledges()), 0)