Beispiel #1
0
    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        db.create_all()
        # Initial Setup
        random_user_id = buid()
        self.user = User(userid=unicode(random_user_id), username=u'lukes{userid}'.format(userid=random_user_id), fullname=u"Luke Skywalker",
            email=u'luke{userid}@dagobah.org'.format(userid=random_user_id))

        db.session.add(self.user)
        db.session.commit()

        self.profile = Profile(title=u"SpaceCon", userid=self.user.userid)
        db.session.add(self.profile)
        db.session.commit()

        self.project = Project(title=u"20000 AD", tagline=u"In a galaxy far far away...", profile=self.profile, user=self.user)
        self.project.make_name()
        db.session.add(self.project)
        db.session.commit()

        self.ticket_client = TicketClient(name=u"test client", client_eventid=u'123', clientid=u'123', client_secret=u'123', client_access_token=u'123', project=self.project)
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.project, event_ticket_types)
        db.session.commit()

        self.session = db.session
    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        init_for('test')
        db.create_all()
        # Initial Setup
        random_user_id = random.randint(1, 1000)
        self.user = User(userid=unicode(random_user_id), username=u'lukes{userid}'.format(userid=random_user_id), fullname=u"Luke Skywalker",
            email=u'luke{userid}@dagobah.org'.format(userid=random_user_id))

        db.session.add(self.user)
        db.session.commit()

        self.profile = Profile(title='SpaceCon', userid=self.user.userid)
        db.session.add(self.profile)
        db.session.commit()

        self.space = ProposalSpace(title='20000 AD', tagline='In a galaxy far far away...', profile=self.profile, user=self.user)
        db.session.add(self.space)
        db.session.commit()

        self.ticket_client = TicketClient(name="test client", client_eventid='123', clientid='123', client_secret='123', client_access_token='123', proposal_space=self.space)
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.space, event_ticket_types)
        db.session.commit()

        self.session = db.session
    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        db.create_all()
        # Initial Setup
        random_user_id = uuid_b58()
        self.user = User(
            username='******'.format(userid=random_user_id.lower()),
            fullname="Luke Skywalker",
            email='luke{userid}@dagobah.org'.format(userid=random_user_id),
        )

        db.session.add(self.user)
        db.session.commit()

        self.organization = Organization(name='spacecon',
                                         title="SpaceCon",
                                         owner=self.user)
        db.session.add(self.organization)
        db.session.commit()
        self.profile = self.organization.profile

        self.project = Project(
            title="20000 AD",
            tagline="In a galaxy far far away...",
            profile=self.profile,
            user=self.user,
        )
        db.session.add(self.project)
        self.project.make_name()
        db.session.commit()

        self.ticket_client = TicketClient(
            name="test client",
            client_eventid='123',
            clientid='123',
            client_secret='123',
            client_access_token='123',
            project=self.project,
        )
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.project, event_ticket_types)
        db.session.commit()

        self.session = db.session
Beispiel #4
0
    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        init_for('test')
        db.create_all()
        # Initial Setup
        random_user_id = random.randint(1, 1000)
        self.user = User(
            userid=unicode(random_user_id),
            username=u'lukes{userid}'.format(userid=random_user_id),
            fullname=u"Luke Skywalker",
            email=u'luke{userid}@dagobah.org'.format(userid=random_user_id))

        db.session.add(self.user)
        db.session.commit()

        self.profile = Profile(title='SpaceCon', userid=self.user.userid)
        db.session.add(self.profile)
        db.session.commit()

        self.space = ProposalSpace(title='20000 AD',
                                   tagline='In a galaxy far far away...',
                                   profile=self.profile,
                                   user=self.user)
        db.session.add(self.space)
        db.session.commit()

        self.ticket_client = TicketClient(name="test client",
                                          client_eventid='123',
                                          clientid='123',
                                          client_secret='123',
                                          client_access_token='123',
                                          proposal_space=self.space)
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.space, event_ticket_types)
        db.session.commit()

        self.session = db.session
Beispiel #5
0
class TestEventModels(unittest.TestCase):
    app = app

    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        db.create_all()
        # Initial Setup
        random_user_id = buid()
        self.user = User(userid=unicode(random_user_id), username=u'lukes{userid}'.format(userid=random_user_id), fullname=u"Luke Skywalker",
            email=u'luke{userid}@dagobah.org'.format(userid=random_user_id))

        db.session.add(self.user)
        db.session.commit()

        self.profile = Profile(title=u"SpaceCon", userid=self.user.userid)
        db.session.add(self.profile)
        db.session.commit()

        self.project = Project(title=u"20000 AD", tagline=u"In a galaxy far far away...", profile=self.profile, user=self.user)
        self.project.make_name()
        db.session.add(self.project)
        db.session.commit()

        self.ticket_client = TicketClient(name=u"test client", client_eventid=u'123', clientid=u'123', client_secret=u'123', client_access_token=u'123', project=self.project)
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.project, event_ticket_types)
        db.session.commit()

        self.session = db.session

    def tearDown(self):
        self.session.rollback()
        db.drop_all()
        self.ctx.pop()

    def test_import_from_list(self):
        # test bookings
        self.ticket_client.import_from_list(ticket_list)
        p1 = Participant.query.filter_by(email=u'*****@*****.**', project=self.project).one_or_none()
        p2 = Participant.query.filter_by(email=u'*****@*****.**', project=self.project).one_or_none()
        p3 = Participant.query.filter_by(email=u'*****@*****.**', project=self.project).one_or_none()
        self.assertEquals(SyncTicket.query.count(), 3)
        self.assertEquals(Participant.query.count(), 3)
        self.assertEquals(len(p1.events), 2)
        self.assertEquals(len(p2.events), 1)
        self.assertEquals(len(p3.events), 1)

        # test cancellations
        self.ticket_client.import_from_list(ticket_list2)
        self.assertEquals(len(p1.events), 2)
        self.assertEquals(len(p2.events), 0)
        self.assertEquals(len(p3.events), 1)

        # test_transfers
        self.ticket_client.import_from_list(ticket_list3)
        p4 = Participant.query.filter_by(email=u'*****@*****.**', project=self.project).one_or_none()
        self.assertEquals(len(p1.events), 2)
        self.assertEquals(len(p2.events), 0)
        self.assertEquals(len(p3.events), 0)
        self.assertEquals(len(p4.events), 1)
class TestEventModels(unittest.TestCase):
    app = app

    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        db.create_all()
        # Initial Setup
        random_user_id = uuid_b58()
        self.user = User(
            username='******'.format(userid=random_user_id.lower()),
            fullname="Luke Skywalker",
            email='luke{userid}@dagobah.org'.format(userid=random_user_id),
        )

        db.session.add(self.user)
        db.session.commit()

        self.organization = Organization(name='spacecon',
                                         title="SpaceCon",
                                         owner=self.user)
        db.session.add(self.organization)
        db.session.commit()
        self.profile = self.organization.profile

        self.project = Project(
            title="20000 AD",
            tagline="In a galaxy far far away...",
            profile=self.profile,
            user=self.user,
        )
        db.session.add(self.project)
        self.project.make_name()
        db.session.commit()

        self.ticket_client = TicketClient(
            name="test client",
            client_eventid='123',
            clientid='123',
            client_secret='123',
            client_access_token='123',
            project=self.project,
        )
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.project, event_ticket_types)
        db.session.commit()

        self.session = db.session

    def tearDown(self):
        self.session.rollback()
        db.drop_all()
        self.ctx.pop()

    def test_import_from_list(self):
        # test bookings
        self.ticket_client.import_from_list(ticket_list)
        p1 = TicketParticipant.query.filter_by(
            email_address=EmailAddress.get('*****@*****.**'),
            project=self.project,
        ).one_or_none()
        p2 = TicketParticipant.query.filter_by(
            email_address=EmailAddress.get('*****@*****.**'),
            project=self.project,
        ).one_or_none()
        p3 = TicketParticipant.query.filter_by(
            email_address=EmailAddress.get('*****@*****.**'),
            project=self.project,
        ).one_or_none()
        self.assertEqual(SyncTicket.query.count(), 3)
        self.assertEqual(TicketParticipant.query.count(), 3)
        self.assertEqual(len(p1.ticket_events), 2)
        self.assertEqual(len(p2.ticket_events), 1)
        self.assertEqual(len(p3.ticket_events), 1)

        # test cancellations
        self.ticket_client.import_from_list(ticket_list2)
        self.assertEqual(len(p1.ticket_events), 2)
        self.assertEqual(len(p2.ticket_events), 0)
        self.assertEqual(len(p3.ticket_events), 1)

        # test_transfers
        self.ticket_client.import_from_list(ticket_list3)
        p4 = TicketParticipant.query.filter_by(
            email_address=EmailAddress.get('*****@*****.**'),
            project=self.project,
        ).one_or_none()
        self.assertEqual(len(p1.ticket_events), 2)
        self.assertEqual(len(p2.ticket_events), 0)
        self.assertEqual(len(p3.ticket_events), 0)
        self.assertEqual(len(p4.ticket_events), 1)
class TestEventModels(unittest.TestCase):
    app = app

    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        db.create_all()
        # Initial Setup
        random_user_id = random.randint(1, 1000)
        self.user = User(
            userid=unicode(random_user_id),
            username=u'lukes{userid}'.format(userid=random_user_id),
            fullname=u"Luke Skywalker",
            email=u'luke{userid}@dagobah.org'.format(userid=random_user_id))

        db.session.add(self.user)
        db.session.commit()

        self.profile = Profile(title='SpaceCon', userid=self.user.userid)
        db.session.add(self.profile)
        db.session.commit()

        self.space = ProposalSpace(title='20000 AD',
                                   tagline='In a galaxy far far away...',
                                   profile=self.profile,
                                   user=self.user)
        db.session.add(self.space)
        db.session.commit()

        self.ticket_client = TicketClient(name="test client",
                                          client_eventid='123',
                                          clientid='123',
                                          client_secret='123',
                                          client_access_token='123',
                                          proposal_space=self.space)
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.space, event_ticket_types)
        db.session.commit()

        self.session = db.session

    def tearDown(self):
        self.session.rollback()
        db.drop_all()
        self.ctx.pop()

    def test_import_from_list(self):
        # test bookings
        self.ticket_client.import_from_list(ticket_list)
        p1 = Participant.query.filter_by(
            email='*****@*****.**',
            proposal_space=self.space).one_or_none()
        p2 = Participant.query.filter_by(
            email='*****@*****.**',
            proposal_space=self.space).one_or_none()
        p3 = Participant.query.filter_by(
            email='*****@*****.**',
            proposal_space=self.space).one_or_none()
        self.assertEquals(SyncTicket.query.count(), 3)
        self.assertEquals(Participant.query.count(), 3)
        self.assertEquals(len(p1.events), 2)
        self.assertEquals(len(p2.events), 1)
        self.assertEquals(len(p3.events), 1)

        # test cancellations
        cancel_list = [SyncTicket.get(self.space, 'o2', 't2')]
        self.ticket_client.import_from_list(ticket_list2,
                                            cancel_list=cancel_list)
        self.assertEquals(len(p1.events), 2)
        self.assertEquals(len(p2.events), 0)

        # test_transfers
        self.ticket_client.import_from_list(ticket_list3)
        self.assertEquals(len(p2.events), 1)
        self.assertEquals(p2.events[0],
                          Event.get(self.space, current_name='spacecon'))
        self.assertEquals(len(p3.events), 0)
class TestEventModels(unittest.TestCase):
    app = app

    def setUp(self):
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        init_for('test')
        db.create_all()
        # Initial Setup
        random_user_id = random.randint(1, 1000)
        self.user = User(userid=unicode(random_user_id), username=u'lukes{userid}'.format(userid=random_user_id), fullname=u"Luke Skywalker",
            email=u'luke{userid}@dagobah.org'.format(userid=random_user_id))

        db.session.add(self.user)
        db.session.commit()

        self.profile = Profile(title='SpaceCon', userid=self.user.userid)
        db.session.add(self.profile)
        db.session.commit()

        self.space = ProposalSpace(title='20000 AD', tagline='In a galaxy far far away...', profile=self.profile, user=self.user)
        db.session.add(self.space)
        db.session.commit()

        self.ticket_client = TicketClient(name="test client", client_eventid='123', clientid='123', client_secret='123', client_access_token='123', proposal_space=self.space)
        db.session.add(self.ticket_client)
        db.session.commit()

        bulk_upsert(self.space, event_ticket_types)
        db.session.commit()

        self.session = db.session

    def tearDown(self):
        self.session.rollback()
        db.drop_all()
        self.ctx.pop()

    def test_import_from_list(self):
        # test bookings
        self.ticket_client.import_from_list(ticket_list)
        p1 = Participant.query.filter_by(email='*****@*****.**', proposal_space=self.space).one_or_none()
        p2 = Participant.query.filter_by(email='*****@*****.**', proposal_space=self.space).one_or_none()
        p3 = Participant.query.filter_by(email='*****@*****.**', proposal_space=self.space).one_or_none()
        self.assertEquals(SyncTicket.query.count(), 3)
        self.assertEquals(Participant.query.count(), 3)
        self.assertEquals(len(p1.events), 2)
        self.assertEquals(len(p2.events), 1)
        self.assertEquals(len(p3.events), 1)

        # test cancellations
        cancel_list = [SyncTicket.get(self.space, 'o2', 't2')]
        self.ticket_client.import_from_list(ticket_list2, cancel_list=cancel_list)
        self.assertEquals(len(p1.events), 2)
        self.assertEquals(len(p2.events), 0)

        # test_transfers
        self.ticket_client.import_from_list(ticket_list3)
        self.assertEquals(len(p2.events), 1)
        self.assertEquals(p2.events[0], Event.get(self.space, current_name='spacecon'))
        self.assertEquals(len(p3.events), 0)