Skip to content

Commit 5d3ca94

Browse files
committed
#872 fix & tests updates
1 parent 5a4a8ed commit 5d3ca94

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

examples/onedrive/files/get_by_abs_url.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
test_username,
1111
)
1212

13-
file_abs_url = "{0}/Shared Documents/Financial Sample.xlsx".format(test_team_site_url)
13+
file_abs_url = "{0}/Shared Documents/Financial Sample.csv".format(test_team_site_url)
1414

1515
client = GraphClient.with_username_and_password(
1616
test_tenant, test_client_id, test_username, test_password
1717
)
18+
19+
# csv_file = client.me.drive.root.upload_file("../../data/Financial Sample.csv").execute_query()
20+
1821
file_item = client.shares.by_url(file_abs_url).drive_item.get().execute_query()
19-
print(file_item.web_url)
22+
23+
result = file_item.get_content().execute_query()
24+
print(result.value)

office365/onedrive/driveitems/driveItem.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,6 @@ def subscriptions(self):
913913

914914
def set_property(self, name, value, persist_changes=True):
915915
super(DriveItem, self).set_property(name, value, persist_changes)
916-
if name == "parentReference":
917-
pass
918916
return self
919917

920918
def get_property(self, name, default_value=None):

office365/onedrive/shares/drive_item.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from office365.onedrive.permissions.permission import Permission
99
from office365.onedrive.sites.site import Site
1010
from office365.runtime.paths.resource_path import ResourcePath
11-
from office365.runtime.paths.v4.entity import EntityPath
1211

1312

1413
class SharedDriveItem(BaseItem):
@@ -48,7 +47,7 @@ def drive_item(self):
4847
"""Used to access the underlying driveItem"""
4948
return self.properties.get(
5049
"driveItem",
51-
DriveItem(self.context, EntityPath("driveItem", self.resource_path)),
50+
DriveItem(self.context, ResourcePath("driveItem", self.resource_path)),
5251
)
5352

5453
@property

tests/onedrive/test_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_14_copy_file(self):
111111
# self.assertIsNotNone(result.value)
112112

113113
def test_15_get_activities_by_interval(self):
114-
end_time = datetime.utcnow()
114+
end_time = datetime.now()
115115
start_time = end_time - timedelta(days=14)
116116
result = self.__class__.target_file.get_activities_by_interval(
117117
start_time, end_time, "day"

tests/onedrive/test_shares.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
3+
from tests import test_team_site_url
4+
from tests.graph_case import GraphTestCase
5+
6+
7+
class TestShares(GraphTestCase):
8+
"""Shares API specific test case"""
9+
10+
@classmethod
11+
def setUpClass(cls):
12+
super(TestShares, cls).setUpClass()
13+
path = "{0}/../data/Financial Sample.xlsx".format(os.path.dirname(__file__))
14+
cls.file_item = cls.client.sites.get_by_url(test_team_site_url).drive.root.upload_file(path).execute_query()
15+
assert cls.file_item.resource_path is not None
16+
17+
@classmethod
18+
def tearDownClass(cls):
19+
cls.file_item.delete_object().execute_query_retry()
20+
21+
def test1_get_file_by_abs_url(self):
22+
file_abs_url = "{0}/Shared Documents/Financial Sample.xlsx".format(
23+
test_team_site_url
24+
)
25+
result = self.client.shares.by_url(file_abs_url).drive_item.get().execute_query()
26+
self.assertIsNotNone(result.resource_path)
27+
self.assertTrue(result.is_file)

0 commit comments

Comments
 (0)