def test_twitter_handle(self): mfg = ManufacturerFactory(twitter_handle="abc123") provider = BaseTapListProvider() looked_up = provider.get_manufacturer( name=mfg.name, twitter_handle="https://twitter.com/foobar", ) self.assertEqual(looked_up, mfg) self.assertEqual(looked_up.twitter_handle, "foobar")
def test_mfg_duplicate_alt_name(self): mfg = ManufacturerFactory(name='Founders') ManufacturerAlternateName.objects.create(name=mfg.name, manufacturer=mfg) ManufacturerAlternateName.objects.create( name='Founders Brewing Co.', manufacturer=mfg, ) provider = BaseTapListProvider() looked_up = provider.get_manufacturer(name=mfg.name) self.assertEqual(looked_up, mfg)
def test_manufacturer_lookup(self): mfg = ManufacturerFactory(name='Stone') provider = BaseTapListProvider() for name in [ 'Stone Brewing Company', 'Stone Brewing', 'Stone', 'Stone Beer Co.', ]: looked_up = provider.get_manufacturer(name) self.assertEqual( mfg, looked_up, f'{looked_up.name} does not match {name}', ) self.assertEqual(Manufacturer.objects.count(), 1, name)
def parse_provider(provider_name): provider = BaseTapListProvider.get_provider(provider_name)() LOG.debug('Got provider: %s', provider.__class__.__name__) venues = provider.get_venues() LOG.debug('Got venues: %s', [str(i) for i in venues]) provider.handle_venues(venues) LOG.debug('Done')
def test_manufacturer_lookup(self): mfg = ManufacturerFactory(name="Stone") provider = BaseTapListProvider() for name in [ "Stone Brewing Company", "Stone Brewing", "Stone", "Stone Beer Co.", ]: looked_up = provider.get_manufacturer(name) self.assertEqual( mfg, looked_up, f"{looked_up.name} does not match {name}", ) self.assertEqual(Manufacturer.objects.count(), 1, name)
class TimestampTestCase(TestCase): def setUp(self): self.venue = VenueFactory() self.provider = BaseTapListProvider() def test_initial_conditions(self): self.assertIsNone(self.venue.tap_list_last_check_time) self.assertIsNone(self.venue.tap_list_last_update_time) self.assertIsNotNone(self.provider.check_timestamp) def test_timestamp_no_time(self): self.provider.update_venue_timestamps(self.venue, None) self.assertIsNone(self.venue.tap_list_last_update_time) self.assertEqual(self.venue.tap_list_last_check_time, self.provider.check_timestamp) def test_with_time(self): timestamp = now() - datetime.timedelta(days=1) self.provider.update_venue_timestamps(self.venue, timestamp) self.assertEqual(self.venue.tap_list_last_update_time, timestamp) self.assertEqual(self.venue.tap_list_last_check_time, self.provider.check_timestamp)
def parse_provider(provider_name): provider = BaseTapListProvider.get_provider(provider_name)() LOG.debug("Got provider: %s", provider.__class__.__name__) venues = provider.get_venues() LOG.debug("Got venues: %s", [str(i) for i in venues]) provider.handle_venues(venues) new_beers = [ i[0] for i in Beer.objects.filter(tweeted_about=False, ).values_list("id") ] if not new_beers: LOG.info("no new beers to tweet about") return LOG.debug("Scheduling tweet about new beers: %s", new_beers) # give ourselves a brief delay to give a quick chance at an untappd # lookup tweet_about_beers.s(new_beers).apply_async(countdown=300) LOG.debug("Done")
def test_collab(self): """Test collaborations (See #321)""" provider = BaseTapListProvider() name = provider.reformat_beer_name( 'Hi-Wire / New Belgium Belgian Stout', 'Hi-Wire') self.assertEqual(name, 'Hi-Wire / New Belgium Belgian Stout')
def test_standard(self): """Test the standard case""" provider = BaseTapListProvider() name = provider.reformat_beer_name('Stone IPA', 'Stone') self.assertEqual(name, 'IPA')
def test_style_strip_none(self): provider = BaseTapListProvider() style = StyleFactory(name='test style') looked_up = provider.get_style('None - TEST STYLE') self.assertEqual(looked_up, style)
def test_yazoo(self): provider = BaseTapListProvider() name = provider.reformat_beer_name("Yazoo Brewing Company Hefeweizen", "Yazoo") self.assertEqual(name, "Hefeweizen")
def test_standard(self): """Test the standard case""" provider = BaseTapListProvider() name = provider.reformat_beer_name("Stone IPA", "Stone") self.assertEqual(name, "IPA")
def setUp(self): self.venue = VenueFactory() self.provider = BaseTapListProvider()