Skip to content

Commit

Permalink
Fix response namespace parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
d3QUone committed Dec 21, 2023
1 parent 37060b1 commit 81deb60
Show file tree
Hide file tree
Showing 12 changed files with 601 additions and 339 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test310.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ jobs:
- name: Run tests
run: |
make test
- name: Run linters
run: |
poetry run pre-commit install
poetry run pre-commit run --all-files
5 changes: 5 additions & 0 deletions .github/workflows/test311.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ jobs:
- name: Run tests
run: |
make test
- name: Run linters
run: |
poetry run pre-commit install
poetry run pre-commit run --all-files
5 changes: 5 additions & 0 deletions .github/workflows/test312.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ jobs:
- name: Run tests
run: |
make test
- name: Run linters
run: |
poetry run pre-commit install
poetry run pre-commit run --all-files
5 changes: 5 additions & 0 deletions .github/workflows/test38.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ jobs:
- name: Run tests
run: |
make test
- name: Run linters
run: |
poetry run pre-commit install
poetry run pre-commit run --all-files
5 changes: 5 additions & 0 deletions .github/workflows/test39.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ jobs:
- name: Run tests
run: |
make test
- name: Run linters
run: |
poetry run pre-commit install
poetry run pre-commit run --all-files
1 change: 1 addition & 0 deletions MAINTAIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Set up environment:
python3 -m pip install poetry==1.5.0
poetry env use 3.11
poetry install
poetry run pre-commit install
```

Run tests:
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,3 @@ Close the client at the end:
```python
await client.close()
```


## Development

Set up env and install dependencies:
```shell
python3 -m pip install poetry==1.5.0
poetry env use 3.11
poetry install
```
2 changes: 1 addition & 1 deletion aiosqs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def parse_xml_result_response(action: str, body: str, logger: Optional[LoggerTyp
)

# Find if it's a single element or a list
xpath = f"./{action}Result"
xpath = f"./*[local-name() = '{action}Result']"
elements = collect_elements(root=root, xpath=xpath)

# Response is a list of objects of the same type
Expand Down
10 changes: 10 additions & 0 deletions aiosqs/tests/fixtures/get_queue_url_namespace.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<GetQueueUrlResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<GetQueueUrlResult>
<QueueUrl>
http://sqs.mcs.mail.ru/account123/example_queue
</QueueUrl>
</GetQueueUrlResult>
<ResponseMetadata>
<RequestId/>
</ResponseMetadata>
</GetQueueUrlResponse>
12 changes: 12 additions & 0 deletions aiosqs/tests/test_get_queue_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ def test_get_queue_url(self):
"QueueUrl": "http://sqs.mcs.mail.ru/account123/example_queue",
},
)

def test_response_with_namespace(self):
res = parse_xml_result_response(
action=self.action,
body=load_fixture("get_queue_url_namespace.xml"),
)
self.assertEqual(
res,
{
"QueueUrl": "http://sqs.mcs.mail.ru/account123/example_queue",
},
)
879 changes: 551 additions & 328 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ lxml = "^4"
[tool.poetry.group.dev.dependencies]
nose2 = "0.12.0"
freezegun = "1.2.2"
pre-commit = "2.17.0"

[tool.black]
line-length = 140
Expand Down

0 comments on commit 81deb60

Please sign in to comment.