コード例 #1
0
ファイル: tests.py プロジェクト: satsuki-chan/ValVerFinal
    def test_appt_edit(self):
        now = datetime.now()
        # Logout any previous user
        response_login = self.appt.get("/logout/", follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)

        # Load an existing appointment for edition defore login
        response = self.appt.get("/appointments/1/edit/")
        assert 'Redirecting' in response.data

        response_login = self.appt.post('/login/', data=dict(
            username='******',
            password='******'), follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)

        # Load an existing appointment for edition after login
        response = self.appt.get("/appointments/1/edit/")
        self.assertEquals(response.status_code, 200)

        # Load a non-existing appointment for edition
        response = self.appt.get("/appointments/99/edit/")
        self.assertNotEquals(response.status_code, 200)
        self.assertEquals(response.status_code, 404)

        # Edit an all-day appointment
        response_appt = self.appt.post('/appointments/5/edit/', data=dict(
            title='New all-day appointment - Modified',
            start=filters.do_datetime(now + timedelta(days=1, seconds=-5300), '%Y-%m-%d %H:%M:%S'),
            end=filters.do_datetime(now + timedelta(days=3, seconds=-3730), '%Y-%m-%d %H:%M:%S'),
            location='Classroom W',
            description='Review class. With another teacher.'), follow_redirects=True)
        self.assertEquals(response_appt.status_code, 200)
        assert 'Edit Appointment' not in response_appt.data

        # Edit a non-existent appointment
        response_appt = self.appt.post('/appointments/99/edit/', data=dict(
            title='A recent appointment - Modified',
            start=filters.do_datetime(now + timedelta(days=4), '%Y-%m-%d %H:%M:%S'),
            end=filters.do_datetime(now + timedelta(days=5), '%Y-%m-%d %H:%M:%S'),
            location='Classroom T',
            description='Tests!!!.'), follow_redirects=True)
        self.assertNotEquals(response.status_code, 200)
        self.assertEquals(response.status_code, 404)
        assert 'Edit Appointment' not in response_appt.data

        response_login = self.appt.get("/logout/", follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)

        response_login = self.appt.post('/login/', data=dict(
            username='******',
            password='******'), follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)

        # Edit an existent appointment with an user that didn't created it
        response = self.appt.get("/appointments/5/edit/")
        self.assertNotEquals(response.status_code, 200)
        self.assertEquals(response.status_code, 403)
コード例 #2
0
ファイル: tests.py プロジェクト: satsuki-chan/ValVerFinal
 def test_do_datetime(self):
     # Without a datetime
     result_datetime = filters.do_datetime(None)
     self.assertEqual('', result_datetime)
     # With datetime and without a date format
     result_datetime = filters.do_datetime(datetime(2014, 4, 10, 13, 11, 35))
     self.assertEqual('2014-04-10 - Thursday at 1:11pm', result_datetime)
     # With datetime and a date format
     result_datetime = filters.do_datetime(datetime(2014, 4, 10, 13, 11, 35), '%d-%m %H:%M:%S')
     self.assertEqual('10-04 13:11:35', result_datetime)
     self.assertNotEqual('2014-04-10 - Thursday at 1:11pm', result_datetime)
コード例 #3
0
    def test_do_datetime(self):
        now = datetime(2010, 11, 11, 15, 12, 0)
        date_filter = fil.do_datetime(now)
        self.assertEqual('2010-11-11 - Thursday at 3:12pm', date_filter)
        self.assertNotEqual('2010-11-12 - Thursday at 3:12pm', date_filter)

        date_filter2 = fil.do_datetime(None)
        self.assertEqual('', date_filter2)

        now = datetime(2010, 11, 11, 15, 12, 0)
        format = '%d-%m-%Y'
        date_filter3 = fil.do_datetime(now, format)
        self.assertEqual('11-11-2010', date_filter3)
コード例 #4
0
    def test_do_datetime(self):
        now = datetime(2010, 11, 11, 15, 12, 0)
        date_filter = fil.do_datetime(now)
        self.assertEqual('2010-11-11 - Thursday at 3:12pm', date_filter)
        self.assertNotEqual('2010-11-12 - Thursday at 3:12pm', date_filter)

        date_filter2 = fil.do_datetime(None)
        self.assertEqual('', date_filter2)

        now = datetime(2010, 11, 11, 15, 12, 0)
        format = '%d-%m-%Y'
        date_filter3 = fil.do_datetime(now, format)
        self.assertEqual('11-11-2010', date_filter3)
コード例 #5
0
ファイル: tests.py プロジェクト: satsuki-chan/ValVerFinal
    def test_appt_create(self):
        now = datetime.now()
        # Logout any previous user
        response_login = self.appt.get("/logout/", follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)

        # Load the appointment creation form before login
        response = self.appt.get("/appointments/create/")
        self.assertNotEquals(response.status_code, 200)
        assert 'Redirecting' in response.data

        # Load the appointment creation form before login
        response = self.appt.get("/appointments/create/", follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)
        assert 'Login' in response.data

        # Login an active user
        response_login = self.appt.post('/login/', data=dict(
            username='******',
            password='******'), follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)

        # Load the appointment creation form after login
        response = self.appt.get("/appointments/create/", follow_redirects=True)
        self.assertEquals(response_login.status_code, 200)
        assert 'Login' not in response.data
        assert 'Add Appointment' in response.data

        # Create an all-day appointment
        response_appt = self.appt.post('/appointments/create/', data=dict(
            title='New all-day appointment',
            start=filters.do_datetime(now + timedelta(days=1), '%Y-%m-%d %H:%M:%S'),
            end=filters.do_datetime(now + timedelta(days=2), '%Y-%m-%d %H:%M:%S'),
            allday=True,
            location='Classroom Z',
            description='Review class'), follow_redirects=True)
        self.assertEquals(response_appt.status_code, 200)
        assert 'Add Appointment' not in response_appt.data

        # Create an appointment
        response_appt = self.appt.post('/appointments/create/', data=dict(
            title='New appointment',
            start=filters.do_datetime(now + timedelta(days=3, seconds=1800), '%Y-%m-%d %H:%M:%S'),
            end=filters.do_datetime(now + timedelta(days=3, seconds=7200), '%Y-%m-%d %H:%M:%S'),
            location='Classroom Y',
            description='Scores review'), follow_redirects=True)
        self.assertEquals(response_appt.status_code, 200)
        assert 'Add Appointment' not in response_appt.data
コード例 #6
0
 def test_datetime_format_None(self):
     now = datetime(2010, 11, 11, 14, 00, 00)
     fecha = filters.do_datetime(now, None)
     self.assertEqual(fecha, '2010-11-11 - Thursday at 2:00pm')
コード例 #7
0
 def test_datetime_None(self):
     fecha = filters.do_datetime(None)
     self.assertNotEqual(fecha, "Today")
     self.assertEqual(fecha, '')
コード例 #8
0
 def test_datetime_with_hour(self):
     now = datetime(2010, 11, 11, 13, 00, 00)
     fecha = filters.do_datetime(now)
     self.assertEqual(fecha, '2010-11-11 - Thursday at 1:00pm')
コード例 #9
0
 def test_datetime_without_hour(self):
     now = date(2010, 11, 11)
     fecha = filters.do_datetime(now)
     self.assertNotEqual(fecha, "2010-11-11 - Thursday")
コード例 #10
0
 def testDatetimeWithHour(self):
     date = datetime(2014, 1, 23, 9, 00, 00)
     result = filters.do_datetime(date)
     self.assertEqual(result, '2014-01-23 - Thursday at 9:00am')
コード例 #11
0
ファイル: unitTests.py プロジェクト: ramonbadillo/viejos_pj
 def testDatetimeWithoutHour(self):
     dat = date(2014, 1, 23)
     result = filters.do_datetime(dat)
     self.assertEqual(result, '2014-01-23 - Thursday at 12:00am')
コード例 #12
0
ファイル: testsUnit.py プロジェクト: juanjo23/flask-web
 def test_datetime_with_hour(self):
     now = datetime(2010, 11, 11, 13, 00, 00)
     fecha = filters.do_datetime(now)
     self.assertEqual(fecha, '2010-11-11 - Thursday at 1:00pm')
コード例 #13
0
ファイル: unitTests.py プロジェクト: ramonbadillo/viejos_pj
 def testDatetimeWithHour(self):
     date = datetime(2014, 1, 23, 9, 00, 00)
     result = filters.do_datetime(date)
     self.assertEqual(result, '2014-01-23 - Thursday at 9:00am')
コード例 #14
0
ファイル: testsUnit.py プロジェクト: juanjo23/flask-web
 def test_datetime_with_format(self):
     a = '%Y-%m-%d - %A'
     now = datetime(2010, 11, 11, 14, 00, 00)
     fecha = filters.do_datetime(now, a)
     self.assertNotEqual(fecha, '2010-11-11 - Thursday at 2:00pm')
コード例 #15
0
ファイル: testsUnit.py プロジェクト: juanjo23/flask-web
 def test_datetime_format_None(self):
     now = datetime(2010, 11, 11, 14, 00, 00)
     fecha = filters.do_datetime(now, None)
     self.assertEqual(fecha, '2010-11-11 - Thursday at 2:00pm')
コード例 #16
0
ファイル: testsUnit.py プロジェクト: juanjo23/flask-web
 def test_datetime_None(self):
     fecha = filters.do_datetime(None)
     self.assertNotEqual(fecha, "Today")
     self.assertEqual(fecha, '')
コード例 #17
0
 def test_datetime_with_format(self):
     a = '%Y-%m-%d - %A'
     now = datetime(2010, 11, 11, 14, 00, 00)
     fecha = filters.do_datetime(now, a)
     self.assertNotEqual(fecha, '2010-11-11 - Thursday at 2:00pm')
コード例 #18
0
ファイル: PU.py プロジェクト: sustaitangel/flaskrepo
 def testDo_datetime(self):
     fecha = filters.do_datetime(datetime(1990, 07, 01, 07, 06, 00))
     self.assertEqual(fecha, '1990-07-01 - Sunday at 7:06am')
     self.assertNotEqual(fecha, '1990-07-01')
コード例 #19
0
 def testDatetimeEmpty(self):
     result = filters.do_datetime(None)
     self.assertEqual(result, '')
コード例 #20
0
ファイル: testsUnit.py プロジェクト: juanjo23/flask-web
 def test_datetime_without_hour(self):
     now = date(2010, 11, 11)
     fecha = filters.do_datetime(now)
     self.assertNotEqual(fecha, "2010-11-11 - Thursday")
コード例 #21
0
ファイル: PU.py プロジェクト: sustaitangel/flaskrepo
 def testDo_datetimeNone(self):
     fecha = filters.do_datetime(None)
     self.assertEqual(fecha, '')
コード例 #22
0
 def testDatetimeWithoutHour(self):
     dat = date(2014, 1, 23)
     result = filters.do_datetime(dat)
     self.assertEqual(result, '2014-01-23 - Thursday at 12:00am')
コード例 #23
0
ファイル: PU.py プロジェクト: sustaitangel/flaskrepo
 def testDatetimeFormat(self):
     formato = '%Y-%m-%d - %A'
     now = datetime(2014, 10, 13, 06, 10, 00)
     fecha = filters.do_datetime(now, formato)
     self.assertNotEqual(fecha, '2014-10-13 - Monday at 6:10am')
コード例 #24
0
ファイル: unitTests.py プロジェクト: ramonbadillo/viejos_pj
 def testDatetimeEmpty(self):
     result = filters.do_datetime(None)
     self.assertEqual(result, '')