Exemple #1
0
    def test_put(self, get_proxy: MagicMock, RequestParser: MagicMock) -> None:
        mock_proxy = get_proxy.return_value = Mock()
        RequestParser().parse_args.return_value = dict(data='{}', index='fake_index')

        response = DocumentUsersAPI().put()
        self.assertEqual(list(response)[1], HTTPStatus.OK)
        mock_proxy.update_document.assert_called_with(data=[], index='fake_index')
Exemple #2
0
    def test_post(self, get_proxy: MagicMock, RequestParser: MagicMock, UserSchema: MagicMock) -> None:
        mock_proxy = get_proxy.return_value = Mock()
        RequestParser().parse_args.return_value = dict(data='{}', index='fake_index')
        expected_value = UserSchema().loads.return_value = Mock()

        response = DocumentUsersAPI().post()
        self.assertEqual(list(response)[1], HTTPStatus.OK)
        mock_proxy.create_document.assert_called_with(data=expected_value, index='fake_index')