Пример #1
0
 def test_contents_with_tweet(self):
     status = random_tweet_status()
     mixer.blend(Tweet, reimbursement=self.reimbursement, status=status)
     expected = self.sample_response
     expected['rosies_tweet'] = self.reimbursement.tweet.get_url()
     url = resolve_url('chamber_of_deputies:reimbursement-detail',
                       document_id=self.reimbursement.document_id)
     resp = self.client.get(url)
     contents = loads(resp.content.decode('utf-8'))
     self.assertEqual(expected, contents)
 def test_contents_with_tweet(self):
     status = random_tweet_status()
     mixer.blend(Tweet, reimbursement=self.reimbursement, status=status)
     expected = self.sample_response.copy()
     expected['rosies_tweet'] = self.reimbursement.tweet.get_url()
     url = resolve_url(
         'chamber_of_deputies:reimbursement-detail',
         document_id=self.reimbursement.document_id
     )
     resp = self.client.get(url)
     contents = loads(resp.content.decode('utf-8'))
     self.assertTrue(contents['rosies_tweet'].endswith(str(status)), f'{status} not found')
     self.assertEqual(expected, contents)
Пример #3
0
 def test_tweets_with_database(self, api):
     tweet = mixer.blend(
         Tweet,
         reimbursement__search_vector=None,
         status=random_tweet_status()
     )
     api.return_value.GetUserTimeline.return_value = range(3)
     with self.settings(**self.credentials):
         command = Command()
     self.assertEqual((0, 1, 2), tuple(command.tweets))
     api.assert_called_once_with(
         '42', '42', '42', '42',
         sleep_on_rate_limit=True
     )
     api.return_value.GetUserTimeline.assert_called_once_with(
         screen_name='RosieDaSerenata',
         count=200,
         include_rts=False,
         exclude_replies=True,
         since_id=tweet.status
     )
 def test_tweets_with_database(self, api):
     tweet = mixer.blend(
         Tweet,
         reimbursement__search_vector=None,
         status=random_tweet_status()
     )
     api.return_value.GetUserTimeline.return_value = range(3)
     with self.settings(**self.credentials):
         command = Command()
     self.assertEqual((0, 1, 2), tuple(command.tweets))
     api.assert_called_once_with(
         '42', '42', '42', '42',
         sleep_on_rate_limit=True
     )
     api.return_value.GetUserTimeline.assert_called_once_with(
         screen_name='RosieDaSerenata',
         count=200,
         include_rts=False,
         exclude_replies=True,
         since_id=tweet.status
     )