Пример #1
0
 def test_request_meetup_form_with_past_date(self):
     """Test add Meetup form with a date that has passed."""
     date = (timezone.now() - timedelta(2)).date()
     time = timezone.now().time()
     data = {'title': 'Foo', 'slug': 'foo', 'date': date, 'time': time,
             'description': "It's a test meetup."}
     form = AddMeetupForm(data=data, created_by=self.systers_user,
                          meetup_location=self.meetup_location)
     self.assertFalse(form.is_valid())
     self.assertTrue(form.errors['date'], ["Date should not be before today's date."])
Пример #2
0
    def test_add_meetup_form(self):
        """Test add Meetup form"""
        invalid_data = {'title': 'abc', 'date': timezone.now().date()}
        form = AddMeetupForm(data=invalid_data,
                             created_by=self.systers_user,
                             meetup_location=self.meetup_location)
        self.assertFalse(form.is_valid())

        date = (timezone.now() + timedelta(2)).date()
        time = timezone.now().time()
        data = {
            'title': 'Foo',
            'slug': 'foo',
            'date': date,
            'time': time,
            'description': "It's a test meetup."
        }
        form = AddMeetupForm(data=data,
                             created_by=self.systers_user,
                             meetup_location=self.meetup_location)
        self.assertTrue(form.is_valid())
        form.save()
        new_meetup = Meetup.objects.get(slug='foo')
        self.assertTrue(new_meetup.title, 'Foo')
        self.assertTrue(new_meetup.created_by, self.systers_user)
        self.assertTrue(new_meetup.meetup_location, self.meetup_location)
Пример #3
0
 def test_add_meetup_form_with_passed_time(self):
     """Test add Meetup form with a time that has passed."""
     date = timezone.now().date()
     time = (timezone.now() - timedelta(2)).time()
     data = {
         'title': 'Foo',
         'slug': 'foo',
         'date': date,
         'time': time,
         'description': "It's a test meetup."
     }
     form = AddMeetupForm(data=data,
                          created_by=self.systers_user,
                          meetup_location=self.meetup_location)
     self.assertFalse(form.is_valid())
     self.assertTrue(form.errors['time'],
                     ["Time should not be a time that has already passed."])
Пример #4
0
    def test_add_meetup_form(self):
        """Test add Meetup form"""
        invalid_data = {'title': 'abc', 'date': timezone.now().date()}
        form = AddMeetupForm(data=invalid_data, created_by=self.systers_user,
                             meetup_location=self.meetup_location)
        self.assertFalse(form.is_valid())

        date = (timezone.now() + timedelta(2)).date()
        time = timezone.now().time()
        data = {'title': 'Foo', 'slug': 'foo', 'date': date, 'time': time,
                'description': "It's a test meetup."}
        form = AddMeetupForm(data=data, created_by=self.user,
                             meetup_location=self.meetup_location)
        self.assertTrue(form.is_valid())
        form.save()
        new_meetup = Meetup.objects.get(slug='foo')
        self.assertTrue(new_meetup.title, 'Foo')
        self.assertTrue(new_meetup.created_by, self.systers_user)
        self.assertTrue(new_meetup.meetup_location, self.meetup_location)
        self.assertEqual(len(mail.outbox), 2)
        self.assertIn(self.user.email, mail.outbox[0].to)
        self.assertIn('New Meetup', mail.outbox[0].subject)
        self.assertIn(self.user2.email, mail.outbox[1].to)
        self.assertIn('New Meetup', mail.outbox[1].subject)