Skip to content

Commit cd8f864

Browse files
committed
Initial commit
0 parents  commit cd8f864

File tree

6 files changed

+170
-0
lines changed

6 files changed

+170
-0
lines changed

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
48+
# uv
49+
uv.lock

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Development Seed
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.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# eoAPI Notifier
2+
3+
Message handler for eoAPI components. A middleware tool that listens to sources for messages and forwards them to output receivers.
4+
5+
## Installation
6+
7+
Install using `uv`:
8+
9+
```bash
10+
uv add eoapi-notifier
11+
```
12+
13+
## Testing
14+
15+
Install test dependencies and run tests with `uv`:
16+
17+
```bash
18+
uv sync --extra test
19+
uv run pytest
20+
```
21+
22+
## License
23+
24+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

eoapi_notifier/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
eoAPI Notifier - Message handler for eoAPI components.
3+
"""
4+
5+
import re
6+
from pathlib import Path
7+
8+
def get_version():
9+
"""Get version from pyproject.toml."""
10+
try:
11+
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
12+
content = pyproject_path.read_text()
13+
match = re.search(r'version\s*=\s*"([^"]+)"', content)
14+
return match.group(1) if match else "unknown"
15+
except Exception:
16+
return "unknown"
17+
18+
__version__ = get_version()
19+
20+
def version():
21+
print(f"Version: {__version__}")
22+
23+
if __name__ == "__main__":
24+
version()

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "eoapi-notifier"
7+
version = "0.0.1"
8+
description = "Message handler for eoAPI components"
9+
requires-python = ">=3.9"
10+
authors = [
11+
{ name = "Development Seed" }
12+
]
13+
14+
[project.optional-dependencies]
15+
test = [
16+
"pytest>=8.4.2",
17+
]

tests/test_notifier.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Tests for eoapi_notifier module.
3+
"""
4+
5+
import re
6+
from io import StringIO
7+
from unittest.mock import patch
8+
9+
import pytest
10+
11+
from eoapi_notifier import get_version, version, __version__
12+
13+
14+
def test_get_version():
15+
"""Test that get_version returns a valid version string."""
16+
ver = get_version()
17+
assert isinstance(ver, str)
18+
assert ver != ""
19+
# Check if it's a valid version format (e.g., "0.0.1" or "unknown")
20+
assert ver == "unknown" or re.match(r"\d+\.\d+\.\d+", ver)
21+
22+
23+
def test_version_attribute():
24+
"""Test that __version__ is set."""
25+
assert isinstance(__version__, str)
26+
assert __version__ != ""
27+
28+
29+
def test_version_function():
30+
"""Test that version function prints expected output."""
31+
with patch('sys.stdout', new=StringIO()) as fake_out:
32+
version()
33+
output = fake_out.getvalue()
34+
assert "Version:" in output
35+
assert __version__ in output

0 commit comments

Comments
 (0)