File tree 4 files changed +13
-11
lines changed
src/msgraph_core/requests
4 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 3
3
import json
4
4
import re
5
5
import urllib .request
6
+ from deprecated import deprecated
6
7
from io import BytesIO
7
8
from typing import Any , Optional , Union
8
9
from urllib .parse import urlparse
14
15
from kiota_abstractions .serialization import Parsable , ParseNode , SerializationWriter
15
16
16
17
18
+ @deprecated ("Use BytesIO type instead" )
17
19
class StreamInterface (BytesIO ):
18
20
pass
19
21
Original file line number Diff line number Diff line change 1
1
import pytest
2
+ from io import BytesIO
2
3
from unittest .mock import Mock
3
4
from urllib .request import Request
4
5
from kiota_abstractions .request_information import RequestInformation
5
6
from kiota_abstractions .serialization import SerializationWriter
6
7
from msgraph_core .requests .batch_request_item import BatchRequestItem
7
8
from msgraph_core .requests .batch_request_content import BatchRequestContent
8
9
from kiota_abstractions .headers_collection import HeadersCollection as RequestHeaders
9
- from msgraph_core .requests .batch_request_item import BatchRequestItem , StreamInterface
10
+ from msgraph_core .requests .batch_request_item import BatchRequestItem
10
11
11
12
12
13
@pytest .fixture
@@ -16,7 +17,7 @@ def request_info1():
16
17
request_info .url = "https://graph.microsoft.com/v1.0/me"
17
18
request_info .headers = RequestHeaders ()
18
19
request_info .headers .add ("Content-Type" , "application/json" )
19
- request_info .content = StreamInterface (b'{"key": "value"}' )
20
+ request_info .content = BytesIO (b'{"key": "value"}' )
20
21
return request_info
21
22
22
23
@@ -27,7 +28,7 @@ def request_info2():
27
28
request_info .url = "https://graph.microsoft.com/v1.0/users"
28
29
request_info .headers = RequestHeaders ()
29
30
request_info .headers .add ("Content-Type" , "application/json" )
30
- request_info .content = StreamInterface (b'{"key": "value"}' )
31
+ request_info .content = BytesIO (b'{"key": "value"}' )
31
32
return request_info
32
33
33
34
Original file line number Diff line number Diff line change 1
1
import pytest
2
- from unittest . mock import Mock
2
+ from io import BytesIO
3
3
from urllib .request import Request
4
4
from kiota_abstractions .request_information import RequestInformation
5
5
from kiota_abstractions .method import Method
6
6
from kiota_abstractions .headers_collection import HeadersCollection as RequestHeaders
7
- from msgraph_core .requests .batch_request_item import BatchRequestItem , StreamInterface
8
- from kiota_abstractions .serialization import SerializationWriter
7
+ from msgraph_core .requests .batch_request_item import BatchRequestItem
9
8
10
9
base_url = "https://graph.microsoft.com/v1.0/me"
11
10
@@ -16,7 +15,7 @@ def request_info():
16
15
request_info .http_method = "GET"
17
16
request_info .url = "f{base_url}/me"
18
17
request_info .headers = RequestHeaders ()
19
- request_info .content = StreamInterface (b'{"key": "value"}' )
18
+ request_info .content = BytesIO (b'{"key": "value"}' )
20
19
return request_info
21
20
22
21
@@ -100,7 +99,7 @@ def test_headers_property(batch_request_item):
100
99
101
100
102
101
def test_body_property (batch_request_item ):
103
- new_body = StreamInterface (b'{"new_key": "new_value"}' )
102
+ new_body = BytesIO (b'{"new_key": "new_value"}' )
104
103
batch_request_item .body = new_body
105
104
assert batch_request_item .body == b'{"new_key": "new_value"}'
106
105
Original file line number Diff line number Diff line change 4
4
from kiota_abstractions .serialization import ParseNode , SerializationWriter
5
5
from unittest .mock import Mock
6
6
7
- from msgraph_core .requests .batch_response_item import BatchResponseItem , StreamInterface
7
+ from msgraph_core .requests .batch_response_item import BatchResponseItem
8
8
9
9
10
10
@pytest .fixture
@@ -42,7 +42,7 @@ def test_headers_property(batch_response_item):
42
42
43
43
44
44
def test_body_property (batch_response_item ):
45
- body = StreamInterface (b"response body" )
45
+ body = BytesIO (b"response body" )
46
46
batch_response_item .body = body
47
47
assert batch_response_item .body == body
48
48
@@ -74,7 +74,7 @@ def test_serialize(batch_response_item):
74
74
batch_response_item .atomicity_group = "group1"
75
75
batch_response_item .status = 200
76
76
batch_response_item .headers = {"Content-Type" : "application/json" }
77
- batch_response_item .body = StreamInterface (b"response body" )
77
+ batch_response_item .body = BytesIO (b"response body" )
78
78
batch_response_item .serialize (writer )
79
79
writer .write_str_value .assert_any_call ('id' , "12345" )
80
80
writer .write_str_value .assert_any_call ('atomicity_group' , "group1" )
You can’t perform that action at this time.
0 commit comments