Exemple #1
0
    def test_update_event(self):
        event_id = self.post_event()
        put_data = {
            'template': {
                'data': [
                    {'name': u'title', 'value': 'EuroPython'},
                    # Note we pass timezone aware datetimes to test
                    # that we'll drop the timezone properly
                    {'name': u'start_time', 'value': u'2014-01-25T09:00Z'},
                    {'name': u'end_time', 'value': u'2014-01-25T18:00Z'},
                    {'name': u'publication_start',
                     'value': u'2014-01-25T09:00Z'},
                    {'name': u'publication_end',
                     'value': u'2014-01-25T18:00Z'},
                ]
            }
        }

        response = self.app.put_json('/v1/events/%s' % event_id,
                                     put_data,
                                     headers=self.WRITE_HEADERS)

        event = Event.get_by_id(event_id)
        self.assertEqual(response.json['status'], 'updated')
        self.assertEqual(event.title, 'EuroPython')
Exemple #2
0
 def test_post_publication_times(self):
     response = self.app.post_json('/v1/events', {
         'template': {
             'data': [
                 {
                     'name': 'title',
                     'value': u'Événement'
                 },
                 {
                     'name': u'start_time',
                     'value': u'2014-01-25T15:00'
                 },
                 {
                     'name': u'end_time',
                     'value': u'2014-01-25T15:00'
                 },
                 {
                     'name': 'publication_start',
                     'value': u'2014-01-25T16:00'
                 },
                 {
                     'name': 'publication_end',
                     'value': u'2014-01-25T17:00'
                 },
             ]
         }
     },
                                   headers=self.WRITE_HEADERS)
     event_data = data_list_to_dict(
         response.json['collection']['items'][0]['data'])
     event_id = event_data['id']
     event = Event.get_by_id(event_id)
     self.assertEqual(event.publication_start, datetime(2014, 1, 25, 16))
     self.assertEqual(event.publication_end, datetime(2014, 1, 25, 17))
Exemple #3
0
    def test_post_tags_and_categories(self):
        event_id = self.post_event([
            {'name': u'title', 'value': 'EuroPython'},
            {'name': "tags",
             'value': [u"Jazz", u"Classical", u"Bourrée auvergnate"]},
            {'name': "categories", 'value': [u"Music", u"音楽"]},
        ])

        event = Event.get_by_id(event_id)
        self.assertEqual(len(event.tags), 3)
        self.assertEqual(event.tags[0].name, u"Jazz")
        self.assertEqual(event.tags[1].name, u"Classical")
        self.assertEqual(event.tags[2].name, u"Bourrée auvergnate")
        self.assertEqual(len(event.categories), 2)
        self.assertEqual(event.categories[0].name, u"Music")
        self.assertEqual(event.categories[1].name, u"音楽")
Exemple #4
0
 def test_post_contact_info(self):
     event_data = [
         {'name': 'title', 'value': u'Événement'},
         {'name': u'start_time', 'value': u'2014-01-25T15:00'},
         {'name': u'end_time', 'value': u'2014-01-25T15:00'},
         {'name': 'press_contact_name', 'value': u'Éléonore'},
         {'name': 'press_contact_email', 'value': u'*****@*****.**'},
         {'name': 'press_contact_phone_number', 'value': u'123456789'},
         {'name': 'ticket_contact_name', 'value': u'Éléonore'},
         {'name': 'ticket_contact_email', 'value': u'*****@*****.**'},
         {'name': 'ticket_contact_phone_number',
          'value': u'00000000'},
     ]
     event_id = self.post_event(event_data)
     event = Event.get_by_id(event_id)
     self.assertEqual(event.press_contact_name, u'Éléonore')
     self.assertEqual(event.press_contact_email, u'*****@*****.**')
     self.assertEqual(event.ticket_contact_phone_number, u'00000000')
Exemple #5
0
 def test_post_contact_info(self):
     event_data = [
         {
             'name': 'title',
             'value': u'Événement'
         },
         {
             'name': u'start_time',
             'value': u'2014-01-25T15:00'
         },
         {
             'name': u'end_time',
             'value': u'2014-01-25T15:00'
         },
         {
             'name': 'press_contact_name',
             'value': u'Éléonore'
         },
         {
             'name': 'press_contact_email',
             'value': u'*****@*****.**'
         },
         {
             'name': 'press_contact_phone_number',
             'value': u'123456789'
         },
         {
             'name': 'ticket_contact_name',
             'value': u'Éléonore'
         },
         {
             'name': 'ticket_contact_email',
             'value': u'*****@*****.**'
         },
         {
             'name': 'ticket_contact_phone_number',
             'value': u'00000000'
         },
     ]
     event_id = self.post_event(event_data)
     event = Event.get_by_id(event_id)
     self.assertEqual(event.press_contact_name, u'Éléonore')
     self.assertEqual(event.press_contact_email, u'*****@*****.**')
     self.assertEqual(event.ticket_contact_phone_number, u'00000000')
Exemple #6
0
 def _test_post_media(self, attrname):
     event_id = self.post_event([
         {'name': u'title', 'value': 'EuroPython'},
         {'name': attrname, "value": [
             {
                 "url": u"http://example.com/abc",
                 "license": u"CC By"
             },
             {
                 "url": u"http://example.com/123",
                 "license": u"Art Libre"
             }
         ]},
     ])
     event = Event.get_by_id(event_id)
     objects = getattr(event, attrname)
     self.assertEqual(len(objects), 2)
     self.assertEqual(objects[0].url, u"http://example.com/abc")
     self.assertEqual(objects[1].license, u"Art Libre")
Exemple #7
0
 def test_post_publication_times(self):
     response = self.app.post_json('/v1/events', {
         'template': {
             'data': [
                 {'name': 'title', 'value': u'Événement'},
                 {'name': u'start_time', 'value': u'2014-01-25T15:00'},
                 {'name': u'end_time', 'value': u'2014-01-25T15:00'},
                 {'name': 'publication_start',
                  'value': u'2014-01-25T16:00'},
                 {'name': 'publication_end', 'value': u'2014-01-25T17:00'},
             ]
         }
     }, headers=self.WRITE_HEADERS)
     event_data = data_list_to_dict(
         response.json['collection']['items'][0]['data'])
     event_id = event_data['id']
     event = Event.get_by_id(event_id)
     self.assertEqual(event.publication_start, datetime(2014, 1, 25, 16))
     self.assertEqual(event.publication_end, datetime(2014, 1, 25, 17))
Exemple #8
0
    def test_update_event(self):
        event_id = self.post_event()
        put_data = {
            'template': {
                'data': [
                    {
                        'name': u'title',
                        'value': 'EuroPython'
                    },
                    # Note we pass timezone aware datetimes to test
                    # that we'll drop the timezone properly
                    {
                        'name': u'start_time',
                        'value': u'2014-01-25T09:00Z'
                    },
                    {
                        'name': u'end_time',
                        'value': u'2014-01-25T18:00Z'
                    },
                    {
                        'name': u'publication_start',
                        'value': u'2014-01-25T09:00Z'
                    },
                    {
                        'name': u'publication_end',
                        'value': u'2014-01-25T18:00Z'
                    },
                ]
            }
        }

        response = self.app.put_json('/v1/events/%s' % event_id,
                                     put_data,
                                     headers=self.WRITE_HEADERS)

        event = Event.get_by_id(event_id)
        self.assertEqual(response.json['status'], 'updated')
        self.assertEqual(event.title, 'EuroPython')
Exemple #9
0
 def _test_post_media(self, attrname):
     event_id = self.post_event([
         {
             'name': u'title',
             'value': 'EuroPython'
         },
         {
             'name':
             attrname,
             "value": [{
                 "url": u"http://example.com/abc",
                 "license": u"CC By"
             }, {
                 "url": u"http://example.com/123",
                 "license": u"Art Libre"
             }]
         },
     ])
     event = Event.get_by_id(event_id)
     objects = getattr(event, attrname)
     self.assertEqual(len(objects), 2)
     self.assertEqual(objects[0].url, u"http://example.com/abc")
     self.assertEqual(objects[1].license, u"Art Libre")
Exemple #10
0
    def test_post_tags_and_categories(self):
        event_id = self.post_event([
            {
                'name': u'title',
                'value': 'EuroPython'
            },
            {
                'name': "tags",
                'value': [u"Jazz", u"Classical", u"Bourrée auvergnate"]
            },
            {
                'name': "categories",
                'value': [u"Music", u"音楽"]
            },
        ])

        event = Event.get_by_id(event_id)
        self.assertEqual(len(event.tags), 3)
        self.assertEqual(event.tags[0].name, u"Jazz")
        self.assertEqual(event.tags[1].name, u"Classical")
        self.assertEqual(event.tags[2].name, u"Bourrée auvergnate")
        self.assertEqual(len(event.categories), 2)
        self.assertEqual(event.categories[0].name, u"Music")
        self.assertEqual(event.categories[1].name, u"音楽")
Exemple #11
0
 def test_uid(self):
     event_id = self.post_event(example_data)
     event = Event.get_by_id(event_id)
     self.assertIn(event_id, event.id)
Exemple #12
0
 def update_database(self):
     event = Event.get_by_id(self.cstruct['data']['id'])
     appstruct = self.validate()
     event.update_from_appstruct(appstruct)
     DBSession.merge(event)
Exemple #13
0
 def test_uid(self):
     event_id = self.post_event(example_data)
     event = Event.get_by_id(event_id)
     self.assertIn(event_id, event.id)
Exemple #14
0
 def insert_into_database(self):
     model_kwargs = self.validate()
     event = Event(**model_kwargs)
     DBSession.add(event)
Exemple #15
0
 def update_database(self):
     event = Event.get_by_id(self.cstruct['data']['id'])
     appstruct = self.validate()
     event.update_from_appstruct(appstruct)
     DBSession.merge(event)