2016-03-22 02:39:46 +01:00
|
|
|
"""
|
|
|
|
Test module for . . .
|
|
|
|
"""
|
|
|
|
# Standard library imports
|
2020-10-06 04:04:22 +02:00
|
|
|
from __future__ import (
|
|
|
|
absolute_import,
|
|
|
|
division,
|
|
|
|
print_function,
|
|
|
|
unicode_literals,
|
|
|
|
)
|
2016-03-22 02:39:46 +01:00
|
|
|
import logging
|
2017-12-18 12:53:01 +01:00
|
|
|
from os.path import abspath, dirname, join, realpath
|
2016-03-22 02:39:46 +01:00
|
|
|
from sys import path
|
|
|
|
|
|
|
|
# Third party imports
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
# Local imports
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
test_dir = realpath(dirname(__file__))
|
2020-10-06 04:04:22 +02:00
|
|
|
src_dir = abspath(join(test_dir, ".."))
|
2016-03-22 02:39:46 +01:00
|
|
|
path.append(src_dir)
|
|
|
|
print(path)
|
|
|
|
|
|
|
|
import pypiserver
|
|
|
|
|
|
|
|
|
2020-10-06 04:04:22 +02:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"conf_options",
|
|
|
|
[
|
|
|
|
{},
|
|
|
|
{"root": "~/stable_packages"},
|
|
|
|
{
|
|
|
|
"root": "~/unstable_packages",
|
|
|
|
"authenticated": "upload",
|
|
|
|
"passwords": "~/htpasswd",
|
|
|
|
},
|
|
|
|
# Verify that the strip parser works properly.
|
|
|
|
{"authenticated": str("upload")},
|
|
|
|
],
|
|
|
|
)
|
2016-03-22 02:39:46 +01:00
|
|
|
def test_paste_app_factory(conf_options, monkeypatch):
|
|
|
|
"""Test the paste_app_factory method"""
|
2020-10-06 04:04:22 +02:00
|
|
|
monkeypatch.setattr(
|
|
|
|
"pypiserver.core.configure", lambda **x: (x, [x.keys()])
|
|
|
|
)
|
2016-03-22 02:39:46 +01:00
|
|
|
pypiserver.paste_app_factory({}, **conf_options)
|
|
|
|
|
2020-10-06 04:04:22 +02:00
|
|
|
|
2017-03-31 12:48:08 +02:00
|
|
|
def test_app_factory(monkeypatch):
|
2020-10-06 04:04:22 +02:00
|
|
|
monkeypatch.setattr(
|
|
|
|
"pypiserver.core.configure", lambda **x: (x, [x.keys()])
|
|
|
|
)
|
2017-03-31 12:48:08 +02:00
|
|
|
assert pypiserver.app() is not pypiserver.app()
|