Skip to content

Commit 3f45c1d

Browse files
committed
feat: add initial validator tests
1 parent 49eb589 commit 3f45c1d

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

tests/functional/validator/__init__.py

Whitespace-only changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import json
2+
3+
import pytest
4+
5+
6+
@pytest.fixture
7+
def schema():
8+
return {
9+
"$schema": "http://json-schema.org/draft-07/schema",
10+
"$id": "http://example.com/example.json",
11+
"type": "object",
12+
"title": "Sample schema",
13+
"description": "The root schema comprises the entire JSON document.",
14+
"examples": [{"message": "hello world", "username": "lessa"}],
15+
"required": ["message", "username"],
16+
"properties": {
17+
"message": {
18+
"$id": "#/properties/message",
19+
"type": "string",
20+
"title": "The message",
21+
"examples": ["hello world"],
22+
},
23+
"username": {
24+
"$id": "#/properties/username",
25+
"type": "string",
26+
"title": "The username",
27+
"examples": ["lessa"],
28+
},
29+
},
30+
}
31+
32+
33+
@pytest.fixture
34+
def raw_event():
35+
return {"message": "hello hello", "username": "blah blah"}
36+
37+
38+
@pytest.fixture
39+
def wrapped_event():
40+
return {"data": {"payload": {"message": "hello hello", "username": "blah blah"}}}
41+
42+
43+
@pytest.fixture
44+
def wrapped_event_json_string():
45+
return {"data": json.dumps({"payload": {"message": "hello hello", "username": "blah blah"}})}
46+
47+
48+
@pytest.fixture
49+
def wrapped_event_base64_json_string():
50+
return {"data": "eyJtZXNzYWdlIjogImhlbGxvIGhlbGxvIiwgInVzZXJuYW1lIjogImJsYWggYmxhaCJ9="}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from aws_lambda_powertools.utilities.validation import validate
2+
3+
4+
def test_validate_raw_event(schema, raw_event):
5+
validate(event=raw_event, schema=schema)
6+
7+
8+
def test_validate_raw_envelope(schema, wrapped_event):
9+
validate(event=wrapped_event, schema=schema, envelope="data.payload")
10+
11+
12+
def test_validate_json_string_envelope(schema, wrapped_event_json_string):
13+
validate(event=wrapped_event_json_string, schema=schema, envelope="powertools_json(data).payload")
14+
15+
16+
def test_validate_base64_string_envelope(schema, wrapped_event_base64_json_string):
17+
validate(event=wrapped_event_base64_json_string, schema=schema, envelope="powertools_json(powertools_base64(data))")
18+
19+
20+
def test_validate_json_string_no_envelope(schema, wrapped_event_json_string):
21+
raise NotImplementedError()
22+
23+
24+
def test_invalid_schema_format_exception():
25+
raise NotImplementedError()
26+
27+
28+
def test_invalid_envelope_expression():
29+
raise NotImplementedError()
30+
31+
32+
def test_invalid_event():
33+
raise NotImplementedError()
34+
35+
36+
def test_apigateway_http_envelope():
37+
raise NotImplementedError()
38+
39+
40+
def test_apigateway_rest_envelope():
41+
raise NotImplementedError()
42+
43+
44+
def test_eventbridge_envelope():
45+
raise NotImplementedError()
46+
47+
48+
def test_sqs_envelope():
49+
raise NotImplementedError()
50+
51+
52+
def test_sns_envelope():
53+
raise NotImplementedError()
54+
55+
56+
def test_cloudwatch_events_schedule_envelope():
57+
raise NotImplementedError()
58+
59+
60+
def test_kinesis_data_stream_envelope():
61+
raise NotImplementedError()
62+
63+
64+
def test_cloudwatch_logs_envelope():
65+
raise NotImplementedError()
66+
67+
68+
def test_validator_incoming():
69+
raise NotImplementedError()
70+
71+
72+
def test_validator_outgoing():
73+
raise NotImplementedError()
74+
75+
76+
def test_validator_incoming_and_outgoing():
77+
raise NotImplementedError()

0 commit comments

Comments
 (0)