예제 #1
0
    def test_export_subcomponents(self):
        """Test to check presence of subcomponents"""
        with self.app.test_request_context():
            test_session = SessionFactory()

            speaker = SpeakerFactory(name="xyz",
                                     email="*****@*****.**",
                                     user_id=1)
            test_session.speakers = [speaker]

            test_cal = icalendar.Calendar.from_ical(ICalExporter().export(
                test_session.event_id))

            cal_content_lines = test_cal.content_lines()
            self.assertIn(
                'URL:http://localhost/v1/events?identifier={}'.format(
                    test_session.event.identifier), cal_content_lines)
            self.assertIn('LOCATION:example', cal_content_lines)
            self.assertIn('ATTENDEE;CN=xyz:MAILTO:[email protected]',
                          cal_content_lines)
예제 #2
0
    def test_export_with_multiple_sessions(self):
        """Test to check event with sessions in pentabarfxml format"""
        with app.test_request_context():
            keynote = SessionFactory(
                title='Keynote',
                starts_at=datetime(2019, 10, 15, 10, 25, 46),
                ends_at=datetime(2019, 10, 15, 11, 10, 46),
                track__name='Amazing Track',
                microlocation__name='Great Hall',
                event__name='Awesome Conference',
                event__starts_at=datetime(2019, 10, 15),
                event__ends_at=datetime(2019, 10, 16, 13, 30, 00))

            UserFactory()
            mario = SpeakerFactoryBase.build(name='Mario Behling', user_id=1)
            keynote.speakers = [
                mario,
                SpeakerFactoryBase.build(name='Hong Phuc Dang', user_id=1)
            ]

            SessionFactoryBase(title='Hot Session',
                               starts_at=datetime(2019, 10, 15, 11, 30, 00),
                               ends_at=datetime(2019, 10, 15, 12, 00, 54))

            future_session = SessionFactoryBase(
                title='Future Session',
                starts_at=datetime(2019, 10, 16, 9, 15, 30),
                ends_at=datetime(2019, 10, 16, 10, 30, 45))

            future_session.speakers = [
                SpeakerFactoryBase.build(name='Pranav Mistry', user_id=1)
            ]

            MicrolocationFactoryBase(name='Assembly Hall')
            end_session = SessionFactoryBase(
                title='Bye Bye Session',
                starts_at=datetime(2019, 10, 16, 11, 30, 20),
                ends_at=datetime(2019, 10, 16, 13, 00, 30),
                microlocation_id=2)

            end_session.speakers = [mario]

            db.session.commit()
            pentabarf_export = PentabarfExporter()
            pentabarf_string = pentabarf_export.export(keynote.event.id)
            pentabarf_original = fromstring(pentabarf_string)

            self.assertEqual(
                pentabarf_original.find('conference/title').text,
                "Awesome Conference")
            self.assertEqual(
                pentabarf_original.find('conference/start').text, '2019-10-15')
            self.assertEqual(
                pentabarf_original.find('conference/end').text, '2019-10-16')
            self.assertEqual(
                pentabarf_original.find('conference/days').text, '1')

            self.assertEqual(
                pentabarf_original.find('day/room').attrib['name'],
                'Great Hall')
            self.assertEqual(
                pentabarf_original.find('day/room/event/title').text,
                'Keynote')
            self.assertEqual(
                pentabarf_original.find('day/room/event/track').text,
                'Amazing Track')
            self.assertEqual(
                pentabarf_original.find('day/room/event/start').text, '10:25')
            self.assertEqual(
                pentabarf_original.find('day/room/event/duration').text,
                '00:45')
            self.assertEqual(
                pentabarf_original.find(
                    'day/room/event/persons/person[@id="2"]').text,
                'Hong Phuc Dang')
            self.assertEqual(
                len(
                    pentabarf_original.find(
                        'day/room/event/persons').getchildren()), 2)

            self.assertEqual(
                pentabarf_original.find('day/room/event[2]/title').text,
                'Hot Session')

            self.assertEqual(
                pentabarf_original.find('day[2]/room/event/title').text,
                'Future Session')
            self.assertEqual(
                pentabarf_original.find(
                    'day[2]/room/event/persons/person').text, 'Pranav Mistry')

            self.assertEqual(
                pentabarf_original.find('day[2]/room[2]').attrib['name'],
                'Assembly Hall')
            self.assertEqual(
                pentabarf_original.find('day[2]/room[2]/event/title').text,
                'Bye Bye Session')
            self.assertEqual(
                pentabarf_original.find('day[2]/room[2]/event/duration').text,
                '01:30')
            self.assertEqual(
                pentabarf_original.find(
                    'day[2]/room[2]/event/persons/person').text,
                'Mario Behling')