Skip to content

Commit caae175

Browse files
committed
Updates
1 parent 892af97 commit caae175

File tree

8 files changed

+57
-34
lines changed

8 files changed

+57
-34
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ repos:
2323
args: [--indent=4, --no-sort-keys]
2424
- id: trailing-whitespace
2525

26-
- repo: https://github.com/psf/black
26+
- repo: https://github.com/psf/black-pre-commit-mirror
2727
rev: 25.1.0
2828
hooks:
2929
- id: black
30+
args: [--config, pyproject.toml]
3031

3132
- repo: https://github.com/PyCQA/flake8
3233
rev: 7.3.0
3334
hooks:
3435
- id: flake8
36+
args: [--max-line-length, "90"]
3537

3638
- repo: https://github.com/ikamensh/flynt/
3739
rev: 1.0.1
@@ -42,9 +44,11 @@ repos:
4244
rev: 6.0.1
4345
hooks:
4446
- id: isort
45-
name: isort (python)
47+
args: [--settings-path, pyproject.toml]
4648

4749
- repo: https://github.com/pre-commit/mirrors-mypy
4850
rev: v1.17.0
4951
hooks:
5052
- id: mypy
53+
pass_filenames: false
54+
args: [--config-file=pyproject.toml, --ignore-missing-imports, "."]

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ help: ## Show this help message
1414
CONTAINER_RUNTIME ?= podman
1515
IMAGE_NAME ?= pattern-service
1616
IMAGE_TAG ?= latest
17-
QUAY_NAMESPACE ?= ansible
17+
18+
ensure-namespace:
19+
@test -n "$$QUAY_NAMESPACE" || (echo "Error: QUAY_NAMESPACE is required to push quay.io" && exit 1)
1820

1921
.PHONY: build
2022
build: ## Build the container image

core/tests/test_views.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def test_pattern_create_view(self):
8989
def test_pattern_delete_view(self):
9090
# Create a separate pattern for deletion
9191
pattern_to_delete = Pattern.objects.create(
92-
collection_name="delete.test", collection_version="1.0.0", pattern_name="deletable_pattern", pattern_definition={}
92+
collection_name="delete.test",
93+
collection_version="1.0.0",
94+
pattern_name="deletable_pattern",
95+
pattern_definition={},
9396
)
9497

9598
url = reverse("pattern-detail", args=[pattern_to_delete.pk])
@@ -118,9 +121,9 @@ def test_label_detail_view(self):
118121
url = reverse("controllerlabel-detail", args=[self.label.id])
119122
response = self.client.get(url)
120123
self.assertEqual(response.status_code, status.HTTP_200_OK)
121-
self.assertIn('id', response.data)
122-
self.assertIn('label_id', response.data)
123-
self.assertEqual(response.data['label_id'], 5)
124+
self.assertIn("id", response.data)
125+
self.assertIn("label_id", response.data)
126+
self.assertEqual(response.data["label_id"], 5)
124127

125128
def test_label_create_view(self):
126129
url = reverse("controllerlabel-list")
@@ -191,19 +194,29 @@ def test_pattern_instance_create_view(self):
191194
def test_pattern_instance_delete_view(self):
192195
# Create a separate instance for deletion
193196
instance_to_delete = PatternInstance.objects.create(
194-
organization_id=999, controller_project_id=111, controller_ee_id=222, credentials={"user": "deletable"}, pattern=self.pattern
197+
organization_id=999,
198+
controller_project_id=111,
199+
controller_ee_id=222,
200+
credentials={"user": "deletable"},
201+
pattern=self.pattern,
195202
)
196203

197204
url = reverse("patterninstance-detail", args=[instance_to_delete.pk])
198205
response = self.client.delete(url)
199206
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
200207

201208
# Verify database change - instance should be deleted
202-
self.assertFalse(PatternInstance.objects.filter(pk=instance_to_delete.pk).exists())
209+
self.assertFalse(
210+
PatternInstance.objects.filter(pk=instance_to_delete.pk).exists()
211+
)
203212

204213
def test_pattern_instance_create_view_with_invalid_pattern(self):
205214
url = reverse("patterninstance-list")
206-
data = {"organization_id": 999, "credentials": {"user": "test"}, "pattern": 99999} # Non-existent pattern ID
215+
data = {
216+
"organization_id": 999,
217+
"credentials": {"user": "test"},
218+
"pattern": 99999,
219+
} # Non-existent pattern ID
207220

208221
response = self.client.post(url, data, format="json")
209222
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
@@ -224,7 +237,12 @@ def test_automation_detail_view(self):
224237

225238
def test_automation_create_view(self):
226239
url = reverse("automation-list")
227-
data = {"automation_type": "job_template", "automation_id": 1234, "primary": False, "pattern_instance": self.pattern_instance.id}
240+
data = {
241+
"automation_type": "job_template",
242+
"automation_id": 1234,
243+
"primary": False,
244+
"pattern_instance": self.pattern_instance.id,
245+
}
228246

229247
response = self.client.post(url, data, format="json")
230248
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
@@ -238,7 +256,10 @@ def test_automation_create_view(self):
238256
def test_automation_delete_view(self):
239257
# Create a separate automation for deletion
240258
automation_to_delete = Automation.objects.create(
241-
automation_type="job_template", automation_id=5555, primary=False, pattern_instance=self.pattern_instance
259+
automation_type="job_template",
260+
automation_id=5555,
261+
primary=False,
262+
pattern_instance=self.pattern_instance,
242263
)
243264

244265
url = reverse("automation-detail", args=[automation_to_delete.pk])
@@ -250,7 +271,11 @@ def test_automation_delete_view(self):
250271

251272
def test_automation_create_view_with_invalid_pattern_instance(self):
252273
url = reverse("automation-list")
253-
data = {"automation_type": "job_template", "automation_id": 1234, "pattern_instance": 99999} # Non-existent pattern instance ID
274+
data = {
275+
"automation_type": "job_template",
276+
"automation_id": 1234,
277+
"pattern_instance": 99999,
278+
} # Non-existent pattern instance ID
254279

255280
response = self.client.post(url, data, format="json")
256281
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

core/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def create(self, request: Request, *args: tuple, **kwargs: dict) -> Response:
3838
return Response(
3939
{
4040
"task_id": task.id,
41-
"message": "Pattern creation initiated. Check task status for progress.",
41+
"message": (
42+
"Pattern creation initiated. Check task status for progress."
43+
),
4244
},
4345
status=status.HTTP_202_ACCEPTED,
4446
)

pattern_service/settings/defaults.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,10 @@
101101
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
102102

103103
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
104+
105+
DATABASES = {
106+
"default": {
107+
"ENGINE": "django.db.backends.sqlite3",
108+
"NAME": BASE_DIR / "db.sqlite3",
109+
}
110+
}

pattern_service/settings/development_defaults.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@
33
ALLOWED_HOSTS = ["localhost", "pattern-service", "127.0.0.1"]
44
BASE_DIR = Path(__file__).resolve().parent.parent
55
DEBUG = True
6-
SECRET_KEY = (
7-
"django-insecure-_f^+pc=x%dd&p8ht4qv7rqr8&a%@j#lda6v!x9353m+)fm8&gk" # notsecret
8-
)
9-
10-
DATABASES = {
11-
"default": {
12-
"ENGINE": "django.db.backends.sqlite3",
13-
"NAME": BASE_DIR / "db.sqlite3",
14-
}
15-
}
6+
SECRET_KEY = "insecure"
167

178
# Logging
189
LOGGING = {

pattern_service/settings/testing_defaults.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,4 @@
22

33
ALLOWED_HOSTS = ["localhost", "pattern-service", "127.0.0.1"]
44
BASE_DIR = Path(__file__).resolve().parent.parent
5-
SECRET_KEY = (
6-
"django-insecure-_f^+pc=x%dd&p8ht4qv7rqr8&a%@j#lda6v!x9353m+)fm8&gk" # notsecret
7-
)
8-
9-
DATABASES = {
10-
"default": {
11-
"ENGINE": "django.db.backends.sqlite3",
12-
"NAME": BASE_DIR / "db.sqlite3",
13-
}
14-
}
5+
SECRET_KEY = "insecure"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ exclude_gitignore = true
6969
strict = true
7070
disallow_any_generics = false
7171
disallow_subclassing_any = false
72+
disallow_untyped_decorators = false
7273

7374
[[tool.mypy.overrides]]
7475
module = ["ansible_base.*", "dotenv.*"]

0 commit comments

Comments
 (0)