Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .github/dependabot.yml
100644 → 100755
Empty file.
Empty file modified .github/release.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/build-release.yaml
100644 → 100755
Empty file.
21 changes: 0 additions & 21 deletions .github/workflows/dagger-ci.yaml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/main-lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint and test
on:
push:
branches: [main]
pull_request:

jobs:
lint-test:
name: Lint and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12.6'
- name: Install deps
run: |
python -m pip install --upgrade pip poetry
poetry install --with dev
- name: Lint with black
run: poetry run black --check .
- name: Test with pytest without integration tests
run: poetry run pytest -m "not integration"

Empty file modified .github/workflows/manual-release.yml
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Get release version
run: echo "PACKAGE_VERSION=$(cat pyproject.toml|grep ^version|cut -d= -f2|tr -d \"|xargs)" >> $GITHUB_ENV
- name: Install dependencies
run: python -m pip install poetry
- name: Get release version
run: poetry version -s >> $GITHUB_ENV
- name: Build release
run: poetry build
- name: Archive release
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Testdata
testdata_*
*test_analyze_member_data.py
vcr_cassettes/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Anonymize Data",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"anonymize-data",
"tests/testdata_fl_api_get_anon.yaml"
],
"justMyCode": false
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"."
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
161 changes: 98 additions & 63 deletions dagger-ci.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,109 @@

import sys

import anyio
import dagger
from dagger import function


async def test():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
# get reference to the local project
src = client.host().directory(
".", exclude=[".git", ".venv", ".venvdagger", "dist", "junit"]
)

python = (
client.container()
.from_("python:3.11-slim")
# Install poetry
.with_exec(
[
"python",
"-m",
"pip",
"install",
"poetry",
"black",
"pylint",
"pytest-cov",
]
)
# Set max workers for poetry
.with_exec(["poetry", "config", "installer.max-workers", "10"])
# mount cloned repository into image
.with_directory("/src", src)
# set current working directory for next commands
.with_workdir("/src")
# install test dependencies
.with_exec(["poetry", "install", "--with", "dev"])
.with_env_variable("API_USERNAME", "DUMMY")
.with_env_variable("API_PASSWORD", "DUMMY")
.with_env_variable("API_BASE_URL", "https://foreninglet.dk/api/")
.with_env_variable("API_VERSION", "version=1")
.with_env_variable("API_MEMBERS_API", "members")
.with_env_variable("API_ACTIVITIES_API", "activities")
.with_env_variable("API_RESIGNED_MEMBERS_API", "members/status/resigned")
.with_env_variable("MEMBERSHIP_KEYWORDS", "medlemskab,medlemsskab")
.with_env_variable("TEST_ENVIRONMENT", "True")
# Check standards
.with_exec(["black", "--check", "--diff", "--color", "."])
# run tests
.with_exec(
[
"poetry",
"run",
"python",
"-m",
"pytest",
"--vcr-record=none",
".",
"--junitxml=junit/test-results.xml",
"--cov=com",
"--cov-report=xml",
"--cov-report=html",
]
class TestPackage:
@function
async def test(self, source: dagger.Directory) -> str:
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
# get reference to the local project
# src = client.host().directory(
# ".", exclude=[".git", ".venv", ".venvdagger", "dist", "junit"]
# )
return await (
self.build_env(source)
.with_env_variable("API_USERNAME", "DUMMY")
.with_env_variable("API_PASSWORD", "DUMMY")
.with_env_variable("API_BASE_URL", "https://foreninglet.dk/api/")
.with_env_variable("API_VERSION", "version=1")
.with_env_variable("API_MEMBERS_API", "members")
.with_env_variable("API_ACTIVITIES_API", "activities")
.with_env_variable(
"API_RESIGNED_MEMBERS_API", "members/status/resigned"
)
.with_env_variable("MEMBERSHIP_KEYWORDS", "medlemskab,medlemsskab")
.with_env_variable("TEST_ENVIRONMENT", "True")
.with_exec(
[
"poetry",
"run",
"python",
"-m",
"pytest",
"--vcr-record=none",
".",
"--junitxml=junit/test-results.xml",
"--cov=com",
"--cov-report=xml",
"--cov-report=html",
]
)
.stdout()
)
)

# execute
await python.sync()

print("Tests succeeded!")
# python = (
# client.container()
# .from_("python:3.11-slim")
# # Install poetry
# .with_exec(
# [
# "python",
# "-m",
# "pip",
# "install",
# "poetry",
# "black",
# "pylint",
# "pytest-cov",
# ]
# )
# # Set max workers for poetry
# .with_exec(["poetry", "config", "installer.max-workers", "10"])
# # mount cloned repository into image
# .with_directory("/src", src)
# # set current working directory for next commands
# .with_workdir("/src")
# # install test dependencies
# .with_exec(["poetry", "install", "--with", "dev"])
# .with_env_variable("API_USERNAME", "DUMMY")
# .with_env_variable("API_PASSWORD", "DUMMY")
# .with_env_variable("API_BASE_URL", "https://foreninglet.dk/api/")
# .with_env_variable("API_VERSION", "version=1")
# .with_env_variable("API_MEMBERS_API", "members")
# .with_env_variable("API_ACTIVITIES_API", "activities")
# .with_env_variable(
# "API_RESIGNED_MEMBERS_API", "members/status/resigned"
# )
# .with_env_variable("MEMBERSHIP_KEYWORDS", "medlemskab,medlemsskab")
# .with_env_variable("TEST_ENVIRONMENT", "True")
# # Check standards
# .with_exec(["black", "--check", "--diff", "--color", "."])
# # run tests
# .with_exec(
# [
# "poetry",
# "run",
# "python",
# "-m",
# "pytest",
# "--vcr-record=none",
# ".",
# "--junitxml=junit/test-results.xml",
# "--cov=com",
# "--cov-report=xml",
# "--cov-report=html",
# ]
# )
# )

# # execute
# await python.sync()

# print("Tests succeeded!")


anyio.run(test)
# anyio.run(test)
6 changes: 6 additions & 0 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "foreninglet-data",
"sdk": "python",
"source": "foreninglet_data",
"engineVersion": "v0.13.3"
}
1 change: 1 addition & 0 deletions foreninglet_data/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sdk/** linguist-generated
4 changes: 4 additions & 0 deletions foreninglet_data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/sdk
/.venv
/**/__pycache__
*analyze_member_data.py
Empty file modified foreninglet_data/__init__.py
100644 → 100755
Empty file.
Empty file modified foreninglet_data/activities.py
100644 → 100755
Empty file.
15 changes: 13 additions & 2 deletions foreninglet_data/api.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def __init__(self) -> None:
self.api_activities_url = (
f"{self.api_base_url}{self.api_activities_path}?{self.api_version}"
)
self.membership_keywords = environ.get("MEMBERSHIP_KEYWORDS")
if isinstance(environ.get("MEMBERSHIP_KEYWORDS"), str):
self.membership_keywords = environ.get("MEMBERSHIP_KEYWORDS").split(",")
else:
self.membership_keywords = environ.get("MEMBERSHIP_KEYWORDS")

def fl_api_get(self, url):
"""
Expand All @@ -80,7 +83,15 @@ def check_api_responds(self):

def get_memberlist(self):
"""Retrieves members from the member API endpoint"""
resp = self.fl_api_get(self.api_members_url)
try:
resp = self.fl_api_get(self.api_members_url)
if resp.status_code != 200:
return {"error": "API did not respond with 200"}
except requests.exceptions.ConnectionError:
return {"error": "Connection error"}
except requests.exceptions.Timeout:
return {"error": "Timeout"}

return json.loads(resp.text)

@use_cassette("tests/cassettes/test_data_fl_api_activities_anon.yaml")
Expand Down
Empty file modified foreninglet_data/data.py
100644 → 100755
Empty file.
Loading
Loading