Пример #1
0
    def call_mocked_command(self):
        mock = MagicMock()
        mock.fb_share_token = 'token'
        mock.fb_share_link = self.url

        cmd = Command()
        cmd.config = mock

        with patch('facebook.GraphAPI.put_wall_post') as mock:
            cmd.handle()
            return mock
    def call_mocked_command(self):
        mock = MagicMock()
        mock.fb_share_token = 'token'
        mock.fb_share_link = self.url

        cmd = Command()
        cmd.config = mock

        with patch('facebook.GraphAPI.put_object') as mock:
            cmd.handle()
            return mock
Пример #3
0
    def call_mocked_command(self, link):
        mock = MagicMock()
        mock.get_renewed_token.return_value = 'token'
        mock.get_attachment.return_value = link

        cmd = Command()

        cmd.get_attachment = mock.get_attachment
        cmd.get_renewed_token = mock.get_renewed_token

        with patch('facebook.GraphAPI.put_wall_post') as mock:
            cmd.handle()
            return mock
Пример #4
0
    def test_shareonfacebook_command(self):
        pet = self.create_pet('Dog', published=False)
        link = {
            'link': 'http://www.test.com/{}'.format(pet.get_absolute_url())
        }

        mock = MagicMock()
        mock.get_renewed_token.return_value = 'token'
        mock.get_attachment.return_value = link

        cmd = Command()

        cmd.get_attachment = mock.get_attachment
        cmd.get_renewed_token = mock.get_renewed_token

        with patch('facebook.GraphAPI.put_wall_post') as mock:
            cmd.handle()

            mock.assert_called_once_with(pet.name, attachment=link)