示例#1
0
 def test_create(self):
     data = {
         'name': 'My bar',
         'website': 'https://www.example.com',
         'instagram_handle': 'example',
         'time_zone': 'America/New_York',
     }
     serializer = VenueSerializer(data=data)
     serializer.is_valid(raise_exception=True)
     instance = serializer.save()
     self.assertIsInstance(instance, Venue)
     for field, value in data.items():
         with self.subTest(field=field):
             if field != 'time_zone':
                 self.assertEqual(getattr(instance, field), value)
             else:
                 self.assertEqual(instance.time_zone.zone, value)
示例#2
0
 def test_display_tap_list_provider(self):
     data = {
         'name': 'My bar',
         'website': 'https://www.example.com',
         'instagram_handle': 'example',
         'time_zone': 'America/New_York',
         'tap_list_provider': 'untappd',
     }
     serializer = VenueSerializer(data=data)
     serializer.is_valid(raise_exception=True)
     instance = serializer.save()
     self.assertIsInstance(instance, Venue)
     serializer = VenueSerializer(instance=instance)
     self.assertEqual(
         serializer.data['tap_list_provider_display'],
         'Untappd',
     )
示例#3
0
 def test_create(self):
     data = {
         "name": "My bar",
         "website": "https://www.example.com",
         "instagram_handle": "example",
         "time_zone": "America/New_York",
         "slug": "my-bar",
     }
     serializer = VenueSerializer(data=data)
     serializer.is_valid(raise_exception=True)
     instance = serializer.save()
     self.assertIsInstance(instance, Venue)
     for field, value in data.items():
         with self.subTest(field=field):
             if field != "time_zone":
                 self.assertEqual(getattr(instance, field), value)
             else:
                 self.assertEqual(instance.time_zone.zone, value)
示例#4
0
 def test_display_tap_list_provider(self):
     data = {
         "name": "My bar",
         "website": "https://www.example.com",
         "instagram_handle": "example",
         "time_zone": "America/New_York",
         "tap_list_provider": "untappd",
         "slug": "my-bar",
     }
     serializer = VenueSerializer(data=data)
     serializer.is_valid(raise_exception=True)
     instance = serializer.save()
     self.assertIsInstance(instance, Venue)
     serializer = VenueSerializer(instance=instance)
     self.assertEqual(
         serializer.data["tap_list_provider_display"],
         "Untappd",
     )
示例#5
0
 def test_bogus_longitude(self):
     data = {
         'name': 'My bar',
         'website': 'https://www.example.com',
         'instagram_handle': 'example',
         'time_zone': 'America/New_York',
         'tap_list_provider': 'untappd',
         'slug': 'my-bar',
         'latitude': 34.8,
         'longitude': 180.00001,
     }
     serializer = VenueSerializer(data=data)
     self.assertFalse(serializer.is_valid(raise_exception=False))
示例#6
0
 def test_bogus_longitude(self):
     data = {
         "name": "My bar",
         "website": "https://www.example.com",
         "instagram_handle": "example",
         "time_zone": "America/New_York",
         "tap_list_provider": "untappd",
         "slug": "my-bar",
         "latitude": 34.8,
         "longitude": 180.00001,
     }
     serializer = VenueSerializer(data=data)
     self.assertFalse(serializer.is_valid(raise_exception=False))