Skip to content

Commit 7c5118a

Browse files
authored
Merge branch 'main' into json_serialize_none_in_list
2 parents fd975c2 + a3493a5 commit 7c5118a

12 files changed

Lines changed: 76 additions & 92 deletions

File tree

.github/dependabot.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
version: 2
22
updates:
33
- package-ecosystem: pip
4-
directory: "/"
4+
directories:
5+
- "/packages/abstractions"
6+
- "/packages/serialization/form"
7+
- "/packages/serialization/json"
8+
- "/packages/serialization/text"
9+
- "/packages/serialization/multipart"
10+
- "/packages/authentication/azure"
11+
- "/packages/http/httpx"
512
schedule:
613
interval: daily
714
open-pull-requests-limit: 10
@@ -17,4 +24,4 @@ updates:
1724
directory: "/"
1825
schedule:
1926
interval: daily
20-
open-pull-requests-limit: 10
27+
open-pull-requests-limit: 10

packages/http/httpx/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ python = ">=3.8,<4.0"
3030
microsoft-kiota-abstractions = {path="../../abstractions/", develop=true}
3131
opentelemetry-api = ">=1.27.0"
3232
opentelemetry-sdk = ">=1.27.0"
33-
httpx = {extras = ["http2"], version = "^0.23.0"}
33+
httpx = {extras = ["http2"], version = ">=0.23,<0.28"}
3434
urllib3 = "^2.2.2"
3535

3636
[tool.poetry.group.dev.dependencies]

packages/serialization/json/kiota_serialization_json/json_parse_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import warnings
66
from datetime import date, datetime, time, timedelta
77
from enum import Enum
8-
from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union
8+
from typing import Any, Callable, List, Optional, TypeVar
99
from uuid import UUID
1010

1111
import pendulum

packages/serialization/json/tests/helpers/union_type.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Any, Callable, Dict, List, Optional
55

66
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
7-
from kiota_abstractions.serialization.parse_node_helper import ParseNodeHelper
87

98
from . import User, User2
109

packages/serialization/json/tests/helpers/user2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass, field
4-
from datetime import date, datetime
5-
from typing import Any, Callable, Dict, List, Optional, TypeVar
4+
from typing import Any, Callable, Dict, Optional, TypeVar
65

76
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
87

Lines changed: 35 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,45 @@
1-
import json
2-
31
import pytest
42

5-
url: str = "https://graph.microsoft.com/v1.0/$metadata#users/$entity"
6-
73

84
@pytest.fixture
95
def user1_json():
10-
return '{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '\
11-
'"office_location": "dunhill", '\
12-
'"updated_at": "2021-07-29T03:07:25Z", '\
13-
'"birthday": "2000-09-04", '\
14-
'"business_phones": ["+1 205 555 0108"], '\
15-
'"mobile_phone": null, '\
16-
'"is_active": true, '\
17-
'"additional_data": {"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity", '\
18-
'"manager": {"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '\
19-
'"updated_at": "2022-01-27T12:59:45.596117+00:00", "is_active": true}, '\
20-
'"approvers": [{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '\
21-
'"updated_at": "2022-01-27T12:59:45.596117+00:00", "is_active": true}, '\
22-
'{"display_name": "John Doe", "age": 32}], '\
23-
'"data": {'\
24-
'"groups": ['\
25-
'{"friends": [{"display_name": "John Doe", "age": 32}]}'\
26-
']'\
27-
'}}}'\
28-
29-
30-
@pytest.fixture
31-
def user2_json():
32-
33-
return '{"id": 2, "display_name": "MOD Administrator", "age": 32, "gpa": 3.9}'
6+
return (
7+
'{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '
8+
'"office_location": "dunhill", '
9+
'"updated_at": "2021-07-29T03:07:25Z", '
10+
'"birthday": "2000-09-04", '
11+
'"business_phones": ["+1 205 555 0108"], '
12+
'"mobile_phone": null, '
13+
'"is_active": true, '
14+
'"additional_data": {"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity", '
15+
'"manager": {"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '
16+
'"updated_at": "2022-01-27T12:59:45.596117+00:00", "is_active": true}, '
17+
'"approvers": [{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '
18+
'"updated_at": "2022-01-27T12:59:45.596117+00:00", "is_active": true}, '
19+
'{"display_name": "John Doe", "age": 32}], '
20+
'"data": {'
21+
'"groups": ['
22+
'{"friends": [{"display_name": "John Doe", "age": 32}]}'
23+
"]"
24+
"}}}"
25+
)
3426

3527

3628
@pytest.fixture
3729
def users_json():
38-
return '[{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '\
39-
'"office_location": "dunhill", '\
40-
'"updated_at": "2021-07-29T03:07:25Z", '\
41-
'"birthday": "2000-09-04", '\
42-
'"business_phones": ["+1 205 555 0108"], '\
43-
'"mobile_phone": null, '\
44-
'"is_active": true}, '\
45-
'{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '\
46-
'"office_location": "dunhill", '\
47-
'"updated_at": "2021-07-29T03:07:25Z", '\
48-
'"birthday": "2000-09-04", '\
49-
'"business_phones": ["+1 205 555 0108"], '\
50-
'"mobile_phone": null, '\
51-
'"is_active": true}]'
52-
53-
54-
@pytest.fixture
55-
def sample_entity_json():
56-
57-
entity_json = json.dumps(
58-
{
59-
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#$entity",
60-
"id": "8f841f30-e6e3-439a-a812-ebd369559c36"
61-
}
30+
return (
31+
'[{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '
32+
'"office_location": "dunhill", '
33+
'"updated_at": "2021-07-29T03:07:25Z", '
34+
'"birthday": "2000-09-04", '
35+
'"business_phones": ["+1 205 555 0108"], '
36+
'"mobile_phone": null, '
37+
'"is_active": true}, '
38+
'{"id": "8f841f30-e6e3-439a-a812-ebd369559c36", '
39+
'"office_location": "dunhill", '
40+
'"updated_at": "2021-07-29T03:07:25Z", '
41+
'"birthday": "2000-09-04", '
42+
'"business_phones": ["+1 205 555 0108"], '
43+
'"mobile_phone": null, '
44+
'"is_active": true}]'
6245
)
63-
return entity_json

packages/serialization/json/tests/unit/test_intersection_wrapper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import json
22
from uuid import UUID
33

4-
import pytest
5-
64
from kiota_serialization_json.json_parse_node import JsonParseNode
75
from kiota_serialization_json.json_serialization_writer import JsonSerializationWriter
86

packages/serialization/json/tests/unit/test_json_parse_node.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from kiota_serialization_json.json_parse_node import JsonParseNode
99
from ..helpers import OfficeLocation, User
1010

11-
url: str = "https://graph.microsoft.com/v1.0/$metadata#users/$entity"
12-
1311

1412
def test_get_str_value():
1513
parse_node = JsonParseNode("Diego Siciliani")
@@ -42,7 +40,7 @@ def test_get_float_value_from_float():
4240
@pytest.mark.parametrize("value", [0, 10, 100])
4341
def test_get_float_value(value: int):
4442
"""
45-
Consider an OpenAPI Specification using the type: number and format: float or double
43+
Consider an OpenAPI Specification using the type: number and format: float or double
4644
Note: The OpenAPI Specification also allows for the use of the type: integer and format: int32 or int64
4745
4846
Consider an API with Price data [0, 0.5, 1, 1.5, 2] and so on
@@ -70,30 +68,30 @@ def test_get_datetime_value_returns_none_with_invalid_str(value: str):
7068

7169

7270
def test_get_datetime_value():
73-
parse_node = JsonParseNode('2022-01-27T12:59:45.596117')
71+
parse_node = JsonParseNode("2022-01-27T12:59:45.596117")
7472
result = parse_node.get_datetime_value()
7573
assert isinstance(result, datetime)
7674

7775

7876
def test_get_date_value():
79-
parse_node = JsonParseNode('2015-04-20')
77+
parse_node = JsonParseNode("2015-04-20")
8078
result = parse_node.get_date_value()
8179
assert isinstance(result, date)
82-
assert str(result) == '2015-04-20'
80+
assert str(result) == "2015-04-20"
8381

8482

8583
def test_get_time_value():
86-
parse_node = JsonParseNode('12:59:45.596117')
84+
parse_node = JsonParseNode("12:59:45.596117")
8785
result = parse_node.get_time_value()
8886
assert isinstance(result, time)
89-
assert str(result) == '12:59:45.596117'
87+
assert str(result) == "12:59:45.596117"
9088

9189

9290
def test_get_timedelta_value():
93-
parse_node = JsonParseNode('PT30S')
91+
parse_node = JsonParseNode("PT30S")
9492
result = parse_node.get_timedelta_value()
9593
assert isinstance(result, timedelta)
96-
assert str(result) == '0:00:30'
94+
assert str(result) == "0:00:30"
9795

9896

9997
def test_get_collection_of_primitive_values():
@@ -109,7 +107,7 @@ def test_get_collection_of_primitive_values_no_type():
109107

110108

111109
def test_get_bytes_value():
112-
parse_node = JsonParseNode('U2Ftd2VsIGlzIHRoZSBiZXN0')
110+
parse_node = JsonParseNode("U2Ftd2VsIGlzIHRoZSBiZXN0")
113111
result = parse_node.get_bytes_value()
114112
assert isinstance(result, bytes)
115113

@@ -159,26 +157,29 @@ def test_get_object_value(user1_json):
159157
assert result.business_phones == ["+1 205 555 0108"]
160158
assert result.is_active is True
161159
assert result.mobile_phone is None
162-
assert result.additional_data["additional_data"][
163-
"@odata.context"] == "https://graph.microsoft.com/v1.0/$metadata#users/$entity"
160+
assert (
161+
result.additional_data["additional_data"]["@odata.context"] ==
162+
"https://graph.microsoft.com/v1.0/$metadata#users/$entity"
163+
)
164164
assert result.additional_data["additional_data"]["manager"] == {
165-
"id": UUID('8f841f30-e6e3-439a-a812-ebd369559c36'),
165+
"id": UUID("8f841f30-e6e3-439a-a812-ebd369559c36"),
166166
"updated_at":
167167
DateTime(2022, 1, 27, 12, 59, 45, 596117, tzinfo=FixedTimezone(0, name="+00:00")),
168-
"is_active": True
168+
"is_active": True,
169169
}
170170
assert result.additional_data["additional_data"]["approvers"] == [
171171
{
172172
"id":
173-
UUID('8f841f30-e6e3-439a-a812-ebd369559c36'),
173+
UUID("8f841f30-e6e3-439a-a812-ebd369559c36"),
174174
"updated_at":
175175
DateTime(2022, 1, 27, 12, 59, 45, 596117, tzinfo=FixedTimezone(0, name="+00:00")),
176176
"is_active":
177-
True
178-
}, {
177+
True,
178+
},
179+
{
179180
"display_name": "John Doe",
180181
"age": 32
181-
}
182+
},
182183
]
183184
assert result.additional_data["additional_data"]["data"] == {
184185
"groups": [{

packages/serialization/json/tests/unit/test_json_parse_node_factory.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ def test_get_root_parse_node(sample_json_string):
2020

2121

2222
def test_get_root_parse_node_no_content_type(sample_json_string):
23-
with pytest.raises(Exception) as e_info:
23+
with pytest.raises(Exception):
2424
factory = JsonParseNodeFactory()
2525
sample_json_string_bytes = sample_json_string.encode('utf-8')
26-
root = factory.get_root_parse_node('', sample_json_string_bytes)
26+
factory.get_root_parse_node('', sample_json_string_bytes)
2727

2828

2929
def test_get_root_parse_node_unsupported_content_type(sample_json_string):
30-
with pytest.raises(Exception) as e_info:
30+
with pytest.raises(Exception):
3131
factory = JsonParseNodeFactory()
3232
sample_json_string_bytes = sample_json_string.encode('utf-8')
33-
root = factory.get_root_parse_node('application/xml', sample_json_string_bytes)
33+
factory.get_root_parse_node('application/xml', sample_json_string_bytes)
3434

3535

3636
def test_get_root_parse_node_empty_json():
37-
with pytest.raises(TypeError) as e_info:
37+
with pytest.raises(TypeError):
3838
factory = JsonParseNodeFactory()
3939
sample_string_bytes = ''.encode('utf-8')
40-
root = factory.get_root_parse_node('application/json', sample_string_bytes)
40+
factory.get_root_parse_node('application/json', sample_string_bytes)
4141

4242

4343
def test_get_valid_content_type():

packages/serialization/json/tests/unit/test_json_serialization_writer_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def test_get_serialization_writer():
1313

1414

1515
def test_get_serialization_writer_no_content_type():
16-
with pytest.raises(TypeError) as e_info:
16+
with pytest.raises(TypeError):
1717
factory = JsonSerializationWriterFactory()
1818
factory.get_serialization_writer('')
1919

2020

2121
def test_get_serialization_writer_unsupported_content_type():
22-
with pytest.raises(Exception) as e_info:
22+
with pytest.raises(Exception):
2323
factory = JsonSerializationWriterFactory()
2424
factory.get_serialization_writer('application/xml')
2525

0 commit comments

Comments
 (0)