Exemple #1
0
 def test_creating_style(self):
     beer = BeerFactory(api_vendor_style='my style')
     self.assertIsNone(beer.style)
     url = reverse('TapListProviderStyleMapping-list'.lower())
     user = UserFactory(is_staff=True)
     self.client.credentials(HTTP_AUTHORIZATION=f'Token {user.auth_token}')
     style = BeerStyleFactory()
     body = {
         'provider_style_name': beer.api_vendor_style,
         'style_id': style.id,
     }
     response = self.client.post(url, body)
     self.assertEqual(
         response.status_code,
         status.HTTP_201_CREATED,
         response.data,
     )
     self.assertEqual(
         response.data['provider_style_name'],
         beer.api_vendor_style,
         response.data,
     )
     self.assertEqual(response.data['style']['id'], style.id, response.data)
     beer.refresh_from_db()
     self.assertEqual(beer.style_id, style.id)
Exemple #2
0
 def test_single_beer_removed_from_draft(self, mock_retry, mock_api):
     beer = BeerFactory()
     with self.settings_context_manager():
         tweet_about_beers([beer.id])  # pylint: disable=no-value-for-parameter
     mock_retry.assert_not_called()
     mock_api.assert_called_once_with(
         consumer_key=self.consumer_key,
         consumer_secret=self.consumer_secret,
         access_token_key=self.api_key,
         access_token_secret=self.api_secret,
     )
     mock_api.return_value.PostUpdate.assert_not_called()
     mock_api.return_value.PostUpdates.assert_not_called()
     beer.refresh_from_db()
     self.assertTrue(beer.tweeted_about)