Skip to content

Commit 982344d

Browse files
authored
Merge pull request #1 from jabez007/refactor-with-updates
Refactor with updates
2 parents 25b15ea + cb24102 commit 982344d

39 files changed

+2842
-486
lines changed

.github/workflows/publish.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Install build tools
21+
run: |
22+
python -m pip install --upgrade build
23+
24+
- name: Build the package
25+
run: |
26+
python -m build
27+
28+
- name: Upload built package as artifact
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: package-distributions
32+
path: dist/
33+
34+
publish:
35+
runs-on: ubuntu-latest
36+
needs: build # Only publish if build succeeds
37+
permissions:
38+
id-token: write
39+
environment:
40+
name: pypi
41+
url: "https://pypi.org/p/mccann_hub-odoo_client_lib"
42+
steps:
43+
- name: Download built package
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: package-distributions
47+
path: dist/
48+
49+
- name: Publish to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
with:
52+
verbose: true
53+
54+
upload-to-release:
55+
runs-on: ubuntu-latest
56+
needs: build # Only upload to release if build succeeds
57+
permissions:
58+
contents: write # Required to upload assets to the release
59+
steps:
60+
- name: Download built package
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: package-distributions
64+
path: dist/
65+
66+
- name: Upload to GitHub Release
67+
uses: softprops/action-gh-release@v2
68+
with:
69+
files: dist/*
70+
71+
verify:
72+
runs-on: ubuntu-latest
73+
needs: publish # Only verify if PyPI upload succeeds
74+
steps:
75+
- name: Install package from PyPI
76+
run: |
77+
python -m pip install mccann_hub-odoo_client_lib
78+
79+
- name: Verify import
80+
run: |
81+
python -c "import mccann_hub.odoolib; print('✅ Import successful')"

.github/workflows/test-publish.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Publish to TestPyPI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.x"
20+
21+
- name: Install build tools
22+
run: |
23+
python -m pip install --upgrade build
24+
25+
- name: Build the package
26+
run: |
27+
python -m build
28+
29+
- name: Upload built package as artifact
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: package-distributions
33+
path: dist/
34+
35+
publish:
36+
runs-on: ubuntu-latest
37+
needs: build # Only publish if build succeeds
38+
permissions:
39+
id-token: write
40+
environment:
41+
name: testpypi
42+
url: "https://test.pypi.org/p/mccann_hub-odoo_client_lib"
43+
steps:
44+
- name: Download built package
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: package-distributions
48+
path: dist/
49+
50+
- name: Publish to TestPyPI
51+
uses: pypa/gh-action-pypi-publish@release/v1
52+
with:
53+
repository-url: "https://test.pypi.org/legacy/"
54+
skip-existing: true
55+
verbose: true
56+
57+
verify:
58+
runs-on: ubuntu-latest
59+
needs: publish # Only verify if TestPyPI upload succeeds
60+
steps:
61+
- name: Install package from TestPyPI
62+
run: |
63+
python -m pip install \
64+
--index-url https://test.pypi.org/simple/ \
65+
--extra-index-url https://pypi.org/simple/ \
66+
mccann_hub-odoo_client_lib
67+
68+
- name: Verify import
69+
run: |
70+
python -c "import mccann_hub.odoolib; print('✅ Import successful')"

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Discover and Run unit tests
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
- master
8+
9+
jobs:
10+
run_tests:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
python_version:
16+
- "3.10"
17+
- "3.11"
18+
- "3.12"
19+
- "3.13"
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Start up containers
26+
run: |
27+
docker compose -f ./test_containers/compose.yaml up --detach --wait --wait-timeout 600
28+
29+
- name: Setup Python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: ${{ matrix.python_version }}
33+
34+
- name: Install requirements
35+
run: |
36+
pip install -r requirements.txt
37+
38+
- name: Run tests
39+
run: |
40+
PYTHONPATH=src python -m unittest discover -s tests

.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
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+
# Ruff stuff:
171+
.ruff_cache/
172+
173+
# PyPI configuration file
174+
.pypirc

README.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Guide
1313

1414
First install the library: ::
1515

16-
pip install odoo-client-lib
16+
pip install mccann_hub-odoo_client_lib
1717

1818
Now copy-paste the following script describing a simple interaction with an Odoo server: ::
1919

20-
import odoolib
20+
import mccann_hub.odoolib as odoolib
2121

2222
connection = odoolib.get_connection(hostname="localhost", database="my_db", \
2323
login="my_user", password="xxx")
@@ -62,6 +62,13 @@ Here are also some considerations about coding using the Odoo Client Library:
6262
- The browse() method can not be used. That method returns a dynamic proxy that lazy loads the rows' data from
6363
the database. That behavior is not implemented in the Odoo Client Library.
6464

65+
Testing
66+
-------
67+
68+
There is a Docker compose file in the `test_containers` directory that will stand up a local instance of Odoo: ::
69+
70+
docker compose -f ./test_containers/compose.yaml up
71+
6572
Compatibility
6673
-------------
6774

0 commit comments

Comments
 (0)