Exemple #1
0
def create_location(requestor_id, location_name, latlng=None, address_dict=None,
                    account_id=None):
    """
    Handles the creation of a ``Venue`` and its ``Address`` and returns 
    the result.
    
    Args:
        requestor_id:
            Name of the OAuth2Client that requested the application.
        location_name:
            Name of the location
        latlng (optional):
            Lattitude and longtitude of location
        address_dict (optional)
            Dictionary containing address data.
            Should contain the following keys: 
                street_line1, street_line2, postal_code, city, country
                
    Returns:
        TODO: documentation
    """
    vm = logic.VenueManager()
    sm = logic.SecurityManager()
    # create venue
    try:
        if not account_id:
            account = sm.lookup_account_for_client(requestor_id)
            account_id = account.id
        venue = vm.create_venue(location_name)
        venue.created_by = account_id
    except ex.TickeeError, e:
        transaction.abort()
        return marshalling.error(e)
Exemple #2
0
 def test_lookup_address(self):
     # Setup
     vm = logic.VenueManager()
     address = vm.create_address("street_line1", 'street_line2',
                                 'postal_code', 'city', 'country_code')
     # Validate
     self.assertEqual(vm.lookup_address_by_id(address.id), address)
Exemple #3
0
 def test_create_venue(self):
     # Setup
     vm = logic.VenueManager()
     # Test
     venue = vm.create_venue("Charlatan")
     # Validate
     self.assertEqual(venue.name, "Charlatan", "Name does not match.")
Exemple #4
0
 def test_add_unexisting_venue_to_eventpart(self):
     # Setup
     em = logic.EventManager()
     vm = logic.VenueManager()
     # Validate
     self.assertRaises(ex.VenueNotFoundError, em.add_venue_to_eventpart,
                       self.eventpart.id, 999)
Exemple #5
0
 def test_add_venue_to_unexisting_eventpart(self):
     # Setup
     em = logic.EventManager()
     vm = logic.VenueManager()
     venue = vm.create_venue("Marktplein Lokeren")
     # Validate
     self.assertRaises(ex.EventPartNotFoundError, em.add_venue_to_eventpart,
                       999, venue.id)
Exemple #6
0
 def test_add_venue_to_eventpart(self):
     # Setup
     em = logic.EventManager()
     vm = logic.VenueManager()
     venue = vm.create_venue("Marktplein Lokeren")
     # Test
     em.add_venue_to_eventpart(self.eventpart.id, venue.id)
     # Validate
     self.assertEqual(self.eventpart.venue, venue,
                      "Venue was not connected successfully")
Exemple #7
0
 def test_find_one_venue_by_name_filter(self):
     # Setup
     vm = logic.VenueManager()
     vm.create_venue("Charlatan")
     vm.create_venue("Varnage")
     # Test
     matches = vm.find_venues_by_filter("arla")
     # Validate
     self.assertEqual(
         len(matches), 1,
         "Incorrect number of results (%s) found." % len(matches))
Exemple #8
0
 def test_create_address(self):
     # Setup
     vm = logic.VenueManager()
     # Test
     address = vm.create_address("street_line1", 'street_line2',
                                 'postal_code', 'city', 'country_code')
     # Validate
     self.assertEqual(address.street_line1, "street_line1",
                      "street_line1 did not match")
     self.assertEqual(address.street_line2, "street_line2",
                      "street_line2 did not match")
     self.assertEqual(address.postal_code, "postal_code",
                      "postal_code did not match")
     self.assertEqual(address.city, "city", "city did not match")
     self.assertEqual(address.country, "country_code",
                      "country_code did not match")
Exemple #9
0
def location_search(name_filter, limit=10):
    """
    Searches for ``Venue`` objects.
    
    Args:
        name_filter:
            Show only venues whose name contains this string
        limit (optional):
            Limit the amount of venues. Defaults to 10.
            
    Returns:
        TODO: documentation
    """
    vm = logic.VenueManager()
    venues = vm.find_venues_by_filter(name_filter, limit)
    venues_info = map(marshalling.venue_to_dict, venues)
    return dict(locations=venues_info)
Exemple #10
0
def show_location(location_id, use_address=True):
    """
    Returns information about the requested location.
    
    Args:
        location_id:
            Id of the requested ``Venue`` information
        use_address (optional):
            Should the address be included. Defaults to True.
            
    Returns:
        TODO: documentation
    """
    vm = logic.VenueManager()
    try:
        venue = vm.lookup_venue_by_id(location_id)
    except ex.VenueNotFoundError:
        return dict(location=None)
    else:
        return dict(location=marshalling.venue_to_dict(venue, 
                                                       include_address=use_address))
Exemple #11
0
 def test_lookup_unexisting_address(self):
     # Setup
     vm = logic.VenueManager()
     # Validate
     self.assertRaises(ex.AddressNotFoundError, vm.lookup_address_by_id,
                       999)
Exemple #12
0
 def test_lookup_unexisting_venue(self):
     # Setup
     vm = logic.VenueManager()
     # Validate
     self.assertRaises(ex.VenueNotFoundError, vm.lookup_venue_by_id, 999)
Exemple #13
0
 def test_lookup_venue(self):
     # Setup
     vm = logic.VenueManager()
     venue = vm.create_venue("Charlatan")
     # Validate
     self.assertEqual(vm.lookup_venue_by_id(venue.id), venue)
Exemple #14
0
 def test_create_duplicate_venue(self):
     # Setup
     vm = logic.VenueManager()
     vm.create_venue("Charlatan")
     # Validate
     self.assertRaises(ex.VenueExistsError, vm.create_venue, "Charlatan")
Exemple #15
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")