pytest-sftpserver


Namepytest-sftpserver JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttp://github.com/ulope/pytest-sftpserver/
Summarypy.test plugin to locally test sftp server connections.
upload_time2019-09-16 16:07:14
maintainer
docs_urlNone
authorUlrich Petri
requires_python
licenseMIT License
keywords py.test pytest plugin server local sftp localhost
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            =================
pytest-sftpserver
=================

.. image:: https://img.shields.io/pypi/v/pytest-sftpserver.svg?style=flat
    :target: https://pypi.python.org/pypi/pytest-sftpserver/
    :alt: Latest Version
.. image:: https://img.shields.io/circleci/build/gh/ulope/pytest-sftpserver/master
    :alt: Circle CI build status
    :target: https://circleci.com/gh/ulope/workflows/pytest-sftpserver
.. image:: https://img.shields.io/codeclimate/coverage/ulope/pytest-sftpserver
    :alt: Code Climate coverage
    :target: https://codeclimate.com/github/ulope/pytest-sftpserver
.. image:: https://img.shields.io/pypi/pyversions/pytest-sftpserver.svg?style=flat
    :target: https://pypi.python.org/pypi/pytest-sftpserver/
    :alt: Supported versions
.. image:: https://img.shields.io/pypi/l/pytest-sftpserver?style=flat&color=20d020
    :target: https://pypi.python.org/pypi/pytest-sftpserver/
    :alt: License
.. image:: https://requires.io/github/ulope/pytest-sftpserver/requirements.svg?branch=master
     :target: https://requires.io/github/ulope/pytest-sftpserver/requirements/?branch=master
     :alt: Requirements Status

pytest-sftpserver is a plugin for `pytest`_ that provides a local SFTP-Server
`fixture`_.

The SFTP-Server provided by this fixture serves content not from files but
directly from Python objects.

Quickstart
==========

Assume you want to test a function that downloads a file from an SFTP-Server:

.. code-block:: python

    from contextlib import closing
    import paramiko
    def get_sftp_file(host, port, username, password, path):
        with closing(paramiko.Transport((host, port))) as transport:
            transport.connect(username=username, password=password)
            with closing(paramiko.SFTPClient.from_transport(transport)) as sftpclient:
                with sftpclient.open(path, "r") as sftp_file:
                    return sftp_file.read()

This plugin allows to test such functions without having to spin up an external
SFTP-Server by providing a pytest `fixture`_ called `sftpserver`. You use it
simply by adding a parameter named `sftpserver` to your test function:

.. code-block:: python

    def test_sftp_fetch(sftpserver):
        with sftpserver.serve_content({'a_dir': {'somefile.txt': "File content"}}):
            assert get_sftp_file(sftpserver.host, sftpserver.port, "user",
                                 "pw", "/a_dir/somefile.txt") == "File content"

As can be seen from this example `sftpserver` serves content directly from
python objects instead of files.


Installation
============

    pip install pytest-sftpserver


Supported Python versions
=========================

This package supports the following Python versions:

- 2.7, 3.5 - 3.7

TODO
====

- Add more documentation
- Add more usage examples
- Add TODOs :)


Version History
===============

1.3.0 - 2019-09-16
------------------
- Updated supported Python versions to 2.7, 3.5 - 3.7.

  Droped (official) support for 3.4.
- Check / format code with ``black``, ``isort`` and ``flake8``.
- Fix return type of ``.read()``. (#15, thanks @WeatherGod)
- Support the ``offset`` parameter on write operations. (#11, #16, thanks @DrNecromant)


1.2.0 - 2018-03-28
------------------

- Updated supported Python versions to 2.7, 3.4 - 3.6.
  Droped (official) support for 2.6 and 3.2, 3.3.
- Now always uses posixpath internally to avoid problems when running on Windows (#7, #8, thanks @dundeemt)
- Fixed broken readme badges (#14, thanks @movermeyer)


1.1.2 - 2015-06-01
------------------

- Fixed a bug in stat size calculation (#4)
- Fixed mkdir() overwriting existing content (#5)


Thanks to @zerok for both bug reports and accompanying tests.


1.1.1 - 2015-04-04
------------------

- Fixed broken `chmod()` behaviour for non-existing 'files' (Thanks @dundeemt)


1.1.0 - 2014-10-15
------------------

- Fixed broken `stat()` behaviour for non-existing 'files'
- Slightly increased test coverage


1.0.2 - 2014-07-27
------------------

- Fixed broken test on Python 2.6


1.0.1 - 2014-07-27
------------------

- Added Python 3.2 support
- Cleaned up tox configuration


1.0.0 - 2014-07-18
------------------

- Initial release


License
=======
Licensed unter the MIT License. See file `LICENSE`.


Inspiration
===========

The implementation and idea for this plugin is in part based upon:

- `pytest-localserver`_
- `sftpserver`_
- The `Twisted Conch in 60 Seconds`_ series (although I ended up not using
  twisted, this was very helpful understanding SFTP internals)


.. _pytest: http://pytest.org/latest/
.. _fixture: http://pytest.org/latest/fixture.html#fixtures-as-function-arguments
.. _pytest-localserver: https://bitbucket.org/basti/pytest-localserver
.. _sftpserver: https://github.com/rspivak/sftpserver
.. _Twisted Conch in 60 Seconds: http://as.ynchrono.us/2011/04/twisted-conch-in-60-seconds-trivial.html



            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/ulope/pytest-sftpserver/",
    "name": "pytest-sftpserver",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "py.test pytest plugin server local sftp localhost",
    "author": "Ulrich Petri",
    "author_email": "mail@ulo.pe",
    "download_url": "https://files.pythonhosted.org/packages/05/45/f0c545cf1bee1556fed7fb3e7eea77a4691255939522b1d677ecb2c04be8/pytest-sftpserver-1.3.0.tar.gz",
    "platform": "",
    "description": "=================\npytest-sftpserver\n=================\n\n.. image:: https://img.shields.io/pypi/v/pytest-sftpserver.svg?style=flat\n    :target: https://pypi.python.org/pypi/pytest-sftpserver/\n    :alt: Latest Version\n.. image:: https://img.shields.io/circleci/build/gh/ulope/pytest-sftpserver/master\n    :alt: Circle CI build status\n    :target: https://circleci.com/gh/ulope/workflows/pytest-sftpserver\n.. image:: https://img.shields.io/codeclimate/coverage/ulope/pytest-sftpserver\n    :alt: Code Climate coverage\n    :target: https://codeclimate.com/github/ulope/pytest-sftpserver\n.. image:: https://img.shields.io/pypi/pyversions/pytest-sftpserver.svg?style=flat\n    :target: https://pypi.python.org/pypi/pytest-sftpserver/\n    :alt: Supported versions\n.. image:: https://img.shields.io/pypi/l/pytest-sftpserver?style=flat&color=20d020\n    :target: https://pypi.python.org/pypi/pytest-sftpserver/\n    :alt: License\n.. image:: https://requires.io/github/ulope/pytest-sftpserver/requirements.svg?branch=master\n     :target: https://requires.io/github/ulope/pytest-sftpserver/requirements/?branch=master\n     :alt: Requirements Status\n\npytest-sftpserver is a plugin for `pytest`_ that provides a local SFTP-Server\n`fixture`_.\n\nThe SFTP-Server provided by this fixture serves content not from files but\ndirectly from Python objects.\n\nQuickstart\n==========\n\nAssume you want to test a function that downloads a file from an SFTP-Server:\n\n.. code-block:: python\n\n    from contextlib import closing\n    import paramiko\n    def get_sftp_file(host, port, username, password, path):\n        with closing(paramiko.Transport((host, port))) as transport:\n            transport.connect(username=username, password=password)\n            with closing(paramiko.SFTPClient.from_transport(transport)) as sftpclient:\n                with sftpclient.open(path, \"r\") as sftp_file:\n                    return sftp_file.read()\n\nThis plugin allows to test such functions without having to spin up an external\nSFTP-Server by providing a pytest `fixture`_ called `sftpserver`. You use it\nsimply by adding a parameter named `sftpserver` to your test function:\n\n.. code-block:: python\n\n    def test_sftp_fetch(sftpserver):\n        with sftpserver.serve_content({'a_dir': {'somefile.txt': \"File content\"}}):\n            assert get_sftp_file(sftpserver.host, sftpserver.port, \"user\",\n                                 \"pw\", \"/a_dir/somefile.txt\") == \"File content\"\n\nAs can be seen from this example `sftpserver` serves content directly from\npython objects instead of files.\n\n\nInstallation\n============\n\n    pip install pytest-sftpserver\n\n\nSupported Python versions\n=========================\n\nThis package supports the following Python versions:\n\n- 2.7, 3.5 - 3.7\n\nTODO\n====\n\n- Add more documentation\n- Add more usage examples\n- Add TODOs :)\n\n\nVersion History\n===============\n\n1.3.0 - 2019-09-16\n------------------\n- Updated supported Python versions to 2.7, 3.5 - 3.7.\n\n  Droped (official) support for 3.4.\n- Check / format code with ``black``, ``isort`` and ``flake8``.\n- Fix return type of ``.read()``. (#15, thanks @WeatherGod)\n- Support the ``offset`` parameter on write operations. (#11, #16, thanks @DrNecromant)\n\n\n1.2.0 - 2018-03-28\n------------------\n\n- Updated supported Python versions to 2.7, 3.4 - 3.6.\n  Droped (official) support for 2.6 and 3.2, 3.3.\n- Now always uses posixpath internally to avoid problems when running on Windows (#7, #8, thanks @dundeemt)\n- Fixed broken readme badges (#14, thanks @movermeyer)\n\n\n1.1.2 - 2015-06-01\n------------------\n\n- Fixed a bug in stat size calculation (#4)\n- Fixed mkdir() overwriting existing content (#5)\n\n\nThanks to @zerok for both bug reports and accompanying tests.\n\n\n1.1.1 - 2015-04-04\n------------------\n\n- Fixed broken `chmod()` behaviour for non-existing 'files' (Thanks @dundeemt)\n\n\n1.1.0 - 2014-10-15\n------------------\n\n- Fixed broken `stat()` behaviour for non-existing 'files'\n- Slightly increased test coverage\n\n\n1.0.2 - 2014-07-27\n------------------\n\n- Fixed broken test on Python 2.6\n\n\n1.0.1 - 2014-07-27\n------------------\n\n- Added Python 3.2 support\n- Cleaned up tox configuration\n\n\n1.0.0 - 2014-07-18\n------------------\n\n- Initial release\n\n\nLicense\n=======\nLicensed unter the MIT License. See file `LICENSE`.\n\n\nInspiration\n===========\n\nThe implementation and idea for this plugin is in part based upon:\n\n- `pytest-localserver`_\n- `sftpserver`_\n- The `Twisted Conch in 60 Seconds`_ series (although I ended up not using\n  twisted, this was very helpful understanding SFTP internals)\n\n\n.. _pytest: http://pytest.org/latest/\n.. _fixture: http://pytest.org/latest/fixture.html#fixtures-as-function-arguments\n.. _pytest-localserver: https://bitbucket.org/basti/pytest-localserver\n.. _sftpserver: https://github.com/rspivak/sftpserver\n.. _Twisted Conch in 60 Seconds: http://as.ynchrono.us/2011/04/twisted-conch-in-60-seconds-trivial.html\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "py.test plugin to locally test sftp server connections.",
    "version": "1.3.0",
    "project_urls": {
        "Homepage": "http://github.com/ulope/pytest-sftpserver/"
    },
    "split_keywords": [
        "py.test",
        "pytest",
        "plugin",
        "server",
        "local",
        "sftp",
        "localhost"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c07a66ce67849514133361887636e0ca187e894bca241686adedd414a06cb50",
                "md5": "81d10792203e4e7e5d80f18aee5b46e5",
                "sha256": "c5e8a37049866d4eabc711db9f1c09e1c02ab72ba290f5fd244939c9a188042f"
            },
            "downloads": -1,
            "filename": "pytest_sftpserver-1.3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "81d10792203e4e7e5d80f18aee5b46e5",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 18347,
            "upload_time": "2019-09-16T16:07:11",
            "upload_time_iso_8601": "2019-09-16T16:07:11.458507Z",
            "url": "https://files.pythonhosted.org/packages/5c/07/a66ce67849514133361887636e0ca187e894bca241686adedd414a06cb50/pytest_sftpserver-1.3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0545f0c545cf1bee1556fed7fb3e7eea77a4691255939522b1d677ecb2c04be8",
                "md5": "475cf25217f9e9c675ee748aa5b038f2",
                "sha256": "b7ac34a23f63d77e27f67b6a81c9418243733f027eeb8a3061d965b2da7e5cab"
            },
            "downloads": -1,
            "filename": "pytest-sftpserver-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "475cf25217f9e9c675ee748aa5b038f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12563,
            "upload_time": "2019-09-16T16:07:14",
            "upload_time_iso_8601": "2019-09-16T16:07:14.610990Z",
            "url": "https://files.pythonhosted.org/packages/05/45/f0c545cf1bee1556fed7fb3e7eea77a4691255939522b1d677ecb2c04be8/pytest-sftpserver-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-09-16 16:07:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ulope",
    "github_project": "pytest-sftpserver",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "circle": true,
    "appveyor": true,
    "tox": true,
    "lcname": "pytest-sftpserver"
}
        
Elapsed time: 0.13193s