Example #1
0
 def setUp(self):
     super(EventManagementTest, self).setUp()
     # create account
     am = logic.AccountManager()
     self.account = am.create_account("Charlatan", "email")
     # create event
     em = logic.EventManager()
     self.event = em.start_event(self.account.id, "Charlatan")
     # create eventpart
     self.eventpart = em.add_eventpart(self.event.id, "Day 1")
Example #2
0
 def test_find_events_by_id(self):
     # Setup
     am = logic.AccountManager()
     account2 = am.create_account("account_name", "email")
     em = logic.EventManager()
     em.start_event(self.account.id, "Event 1")
     em.start_event(self.account.id, "Event 2")
     em.start_event(account2.id, "Event 3")
     # Test
     events = em.find_events(self.account.id)
     print events
     # Validate
     self.assertEqual(len(events), 2,
                      "Not all matching events were returned")
Example #3
0
 def setUp(self):
     super(TicketTypeCreationTest, self).setUp()
     # Create a user
     self.user = User("email")
     Session.add(self.user)
     Session.flush()
     # Create Account
     am = logic.AccountManager()
     self.account = am.create_account("Charlatan", "email")
     # Create Event
     em = logic.EventManager()
     self.event = em.start_event(self.account.id,
                                 "Gentse Feesten @ Charlatan")
     # Create EventPart
     self.eventpart = em.add_eventpart(self.event.id)
Example #4
0
def create_account(user_id, account_name, email):
    """
    Entrypoint for creating an account and returning its information back as a
    dictionary. 
    
    Args:
        user_id:
            Id of the user who will own the account
        account_name
            Name of the account to create
        email
            Email of the account. This should be a general email address
            and not a user-specific one.

    Returns:
        A dictionary containing the information of the newly created account
        including its identifier. A ``created`` key-value pair is added 
        indicating the success of the attempt. For example:
        
        {'created': True,
         'account': {"id": 42, "name": "Tickee", "email": "*****@*****.**"}}
         
        The dictionary will only contain the created key if the attempt was not
        successful:
        
        {'created': False}
    """
    am = logic.AccountManager()
    sm = logic.SecurityManager()
    try:
        # find user
        um = logic.UserManager()
        user = um.lookup_user_by_id(user_id)
        # create account
        account = am.create_account(account_name, email)
        # create default oauth2 client
        client = sm.create_oauth_client()
        account.client_id = client.id
    except ex.TickeeError, e:
        transaction.abort()
        # build failed result
        return marshalling.error(e)
Example #5
0
def account_exists(account_name):
    """
    Entrypoint for checking if an account already exists with a particular
    account_name.
    
    Args:
        account_name:
            The name of the account that should be checked.
    
    Returns:
        If an account exists with the passed account_name, it will return:
            {'exists': True}
        The value will be False if it does not exist.
    """
    am = logic.AccountManager()
    try:
        am.lookup_account_by_name(account_name)
    except ex.TickeeError, e:
        transaction.abort()
        return dict(exists=False)
Example #6
0
def account_info(oauth_client_id, account_id, include_events=False):
    """
    Entrypoint for viewing account information. If the account_id contains None,
    it will return the info of the account attached to the oauth client.
    
    Args:
        oauth_client_id
            Id of the OAuth2 client asking for the information.
        account_id
            The id of the account to return
        include_events
            If specified also returns a list of events owned by the account.
        
    Returns:
        A dictionary containing the information of the account
        including its identifier.
        
        {'account': 
            {"id": 42, 
             "name": "Tickee", 
             "email": "*****@*****.**",
             "events": [{'id': 1, 'name': 'Tickee Event'}, .. ]}}
         
        The dictionary will contain a null account if no account found:
        
        {'account': null}
    """
    am = logic.AccountManager()
    sm = logic.SecurityManager()
    try:
        if account_id:
            account = am.lookup_account_by_id(account_id)
        else:
            account = sm.lookup_account_for_client(oauth_client_id)
    except ex.TickeeError as e:
        return marshalling.error(e)
    else:
        return dict(
            account=marshalling.account_to_dict(account, include_events))
Example #7
0
 def setUp(self):
     super(EventCreationTest, self).setUp()
     # create account
     am = logic.AccountManager()
     self.account = am.create_account("Charlatan", "email")
Example #8
0
from tickee import logic
from tickee.db.models.event import Event
import sqlahelper
import tests
import tickee.exceptions as ex

Session = sqlahelper.get_session()

am = logic.AccountManager()
vm = logic.VenueManager()
tm = logic.TicketManager()
em = logic.EventManager()
om = logic.OrderManager()


class CreateEventTest(tests.BaseTestCase):
    def setUp(self):
        super(CreateEventTest, self).setUp()
        self.account = am.create_account("accountname", "email")
        self.venue = vm.create_venue("venuename")

    # init

    def test_create_event(self):
        # Test
        event = Event("name", self.venue.id, self.account.id)
        Session.add(event)
        Session.flush()
        # Validate
        self.assertIsInstance(event, Event)
        self.assertEqual(event.name, "name")