pytest-scim2-server 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,171 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # PyPI configuration file
171
+ .pypirc
@@ -0,0 +1 @@
1
+ .dotfiles/mercurial/.hgignore
@@ -0,0 +1,24 @@
1
+ ---
2
+ repos:
3
+ - repo: https://github.com/astral-sh/ruff-pre-commit
4
+ rev: 'v0.9.2'
5
+ hooks:
6
+ - id: ruff
7
+ args: [--fix, --exit-non-zero-on-fix]
8
+ - id: ruff-format
9
+ - repo: https://github.com/pre-commit/pre-commit-hooks
10
+ rev: v5.0.0
11
+ hooks:
12
+ - id: fix-byte-order-marker
13
+ - id: trailing-whitespace
14
+ exclude: "\\.svg$|\\.map$|\\.min\\.css$|\\.min\\.js$|\\.po$|\\.pot$"
15
+ - id: end-of-file-fixer
16
+ exclude: "\\.svg$|\\.map$|\\.min\\.css$|\\.min\\.js$|\\.po$|\\.pot$"
17
+ - id: check-toml
18
+ - repo: https://github.com/codespell-project/codespell
19
+ rev: v2.3.0
20
+ hooks:
21
+ - id: codespell
22
+ additional_dependencies:
23
+ - tomli
24
+ args: [--write-changes]
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,3 @@
1
+ # 0.1.0 - 2025-01-27
2
+
3
+ - Initial release.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Éloi Rivard
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-scim2-server
3
+ Version: 0.1.0
4
+ Summary: SCIM2 server fixture for Pytest
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: portpicker>=1.6.0
8
+ Requires-Dist: pytest>=8.3.4
9
+ Requires-Dist: scim2-server>=0.1.4
10
+ Description-Content-Type: text/markdown
11
+
12
+ # pytest-scim2-server
13
+
14
+ SCIM2 server fixture for Pytest
15
+
16
+ ## Installation
17
+
18
+ ```
19
+ pip install pytest-scim2-server
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ pytest-scim2-server creates a ``scim2_server`` fixture that runs an instance of [scim2-server](https://github.com/python-scim/scim2-server) on a random port, in a dedicated thread.
25
+
26
+ ```python
27
+ import requests
28
+
29
+ def test_scim_foobar(scim2_server):
30
+ host, port = scim2_server
31
+
32
+ res = request.get(f"http://{host}:{port}")
33
+ ...
34
+ ```
35
+
36
+ Note that you can use [scim2-client](https://scim2-client.readthedocs.io) to interact with the SCIM server.
37
+
38
+ ```python
39
+ import pytest
40
+ from httpx import Client
41
+ from scim2_client.engines.httpx import SyncSCIMClient
42
+
43
+
44
+ @pytest.fixture(scope="session")
45
+ def scim_client(scim2_server):
46
+ host, port = scim2_server
47
+ http_client = Client(base_url=f"http://{host}:{port}")
48
+ scim_client = SyncSCIMClient(http_client)
49
+ scim_client.discover()
50
+ return scim_client
51
+
52
+
53
+ def test_scim2_server(scim_client):
54
+ User = scim_client.get_resource_model("User")
55
+ user = User(user_name="bjensen@example.com")
56
+ response = scim_client.create(user)
57
+
58
+ users = scim_client.query(User)
59
+ assert users.resources[0].id == response.id
60
+ ```
@@ -0,0 +1,49 @@
1
+ # pytest-scim2-server
2
+
3
+ SCIM2 server fixture for Pytest
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ pip install pytest-scim2-server
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ pytest-scim2-server creates a ``scim2_server`` fixture that runs an instance of [scim2-server](https://github.com/python-scim/scim2-server) on a random port, in a dedicated thread.
14
+
15
+ ```python
16
+ import requests
17
+
18
+ def test_scim_foobar(scim2_server):
19
+ host, port = scim2_server
20
+
21
+ res = request.get(f"http://{host}:{port}")
22
+ ...
23
+ ```
24
+
25
+ Note that you can use [scim2-client](https://scim2-client.readthedocs.io) to interact with the SCIM server.
26
+
27
+ ```python
28
+ import pytest
29
+ from httpx import Client
30
+ from scim2_client.engines.httpx import SyncSCIMClient
31
+
32
+
33
+ @pytest.fixture(scope="session")
34
+ def scim_client(scim2_server):
35
+ host, port = scim2_server
36
+ http_client = Client(base_url=f"http://{host}:{port}")
37
+ scim_client = SyncSCIMClient(http_client)
38
+ scim_client.discover()
39
+ return scim_client
40
+
41
+
42
+ def test_scim2_server(scim_client):
43
+ User = scim_client.get_resource_model("User")
44
+ user = User(user_name="bjensen@example.com")
45
+ response = scim_client.create(user)
46
+
47
+ users = scim_client.query(User)
48
+ assert users.resources[0].id == response.id
49
+ ```
@@ -0,0 +1,85 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pytest-scim2-server"
7
+ version = "0.1.0"
8
+ description = " SCIM2 server fixture for Pytest "
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "portpicker>=1.6.0",
13
+ "pytest>=8.3.4",
14
+ "scim2-server>=0.1.4",
15
+ ]
16
+
17
+ [dependency-groups]
18
+ dev = [
19
+ "pre-commit-uv>=4.1.4",
20
+ "pytest-cov>=6.0.0",
21
+ "scim2-client[httpx]>=0.5.1",
22
+ "tox-uv>=1.16.0",
23
+ ]
24
+
25
+ [project.entry-points."pytest11"]
26
+ scim2_server = "pytest_scim2_server"
27
+
28
+ [tool.ruff.lint]
29
+ select = [
30
+ "B", # flake8-bugbear
31
+ "D", # pydocstyle
32
+ "E", # pycodestyle
33
+ "F", # pyflakes
34
+ "I", # isort
35
+ "UP", # pyupgrade
36
+ ]
37
+ ignore = [
38
+ "E501", # line-too-long
39
+ "E722", # bare-except
40
+ "D100", # public module
41
+ "D101", # public class
42
+ "D102", # public method
43
+ "D103", # public function
44
+ "D104", # public package
45
+ "D105", # magic method
46
+ "D106", # nested class
47
+ "D107", # public init
48
+ "D203", # no-blank-line-before-class
49
+ "D213", # multi-line-summary-second-line
50
+ ]
51
+
52
+ [tool.ruff.lint.isort]
53
+ force-single-line = true
54
+
55
+ [tool.ruff.format]
56
+ docstring-code-format = true
57
+
58
+ [tool.tox]
59
+ requires = ["tox>=4.19"]
60
+ env_list = [
61
+ "style",
62
+ "py310",
63
+ "py311",
64
+ "py312",
65
+ "py313",
66
+ "minversions",
67
+ ]
68
+
69
+ [tool.tox.env_run_base]
70
+ runner = "uv-venv-lock-runner"
71
+ with_dev = true
72
+ commands = [
73
+ ["pytest", "--showlocals", "--full-trace", "{posargs}"],
74
+ ]
75
+
76
+ [tool.tox.env.style]
77
+ runner = "uv-venv-runner"
78
+ commands = [
79
+ ["pre-commit", "run", "--all-files", "--show-diff-on-failure"],
80
+ ]
81
+
82
+ [tool.tox.env.minversions]
83
+ runner = "uv-venv-lock-runner"
84
+ with_dev = true
85
+ uv_resolution = "lowest-direct"
@@ -0,0 +1,34 @@
1
+ import threading
2
+ import wsgiref.simple_server
3
+
4
+ import portpicker
5
+ import pytest
6
+ from scim2_server.backend import InMemoryBackend
7
+ from scim2_server.provider import SCIMProvider
8
+ from scim2_server.utils import load_default_resource_types
9
+ from scim2_server.utils import load_default_schemas
10
+
11
+
12
+ @pytest.fixture(scope="session")
13
+ def scim2_server():
14
+ """SCIM2 server running in a thread."""
15
+ backend = InMemoryBackend()
16
+ provider = SCIMProvider(backend)
17
+
18
+ for schema in load_default_schemas().values():
19
+ provider.register_schema(schema)
20
+
21
+ for resource_type in load_default_resource_types().values():
22
+ provider.register_resource_type(resource_type)
23
+
24
+ host = "localhost"
25
+ port = portpicker.pick_unused_port()
26
+ httpd = wsgiref.simple_server.make_server(host, port, provider)
27
+
28
+ server_thread = threading.Thread(target=httpd.serve_forever)
29
+ server_thread.start()
30
+ try:
31
+ yield host, port
32
+ finally:
33
+ httpd.shutdown()
34
+ server_thread.join()
File without changes
@@ -0,0 +1,21 @@
1
+ import pytest
2
+ from httpx import Client
3
+ from scim2_client.engines.httpx import SyncSCIMClient
4
+
5
+
6
+ @pytest.fixture(scope="session")
7
+ def scim_client(scim2_server):
8
+ host, port = scim2_server
9
+ http_client = Client(base_url=f"http://{host}:{port}")
10
+ scim_client = SyncSCIMClient(http_client)
11
+ scim_client.discover()
12
+ return scim_client
13
+
14
+
15
+ def test_scim2_server(scim_client):
16
+ User = scim_client.get_resource_model("User")
17
+ user = User(user_name="bjensen@example.com")
18
+ response = scim_client.create(user)
19
+
20
+ users = scim_client.query(User)
21
+ assert users.resources[0].id == response.id