How to use the onedrivesdk.model.item_reference.ItemReference function in onedrivesdk

To help you get started, we’ve selected a few onedrivesdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OneDrive / onedrive-sdk-python / testonedrivesdk / test_models.py View on Github external
def test_serialization_different_datetime(self):
        """
        Test the serialization of the dict-backed models, seeing that
        the correct objects are returned when called. Specifically,
        ensure that the datetime can be parsed correctly when the format
        does not fit exactly what we always return
        """
        ref = ItemReference();
        ref._prop_dict = {"id": self.id}

        response = {"name":self.name, "folder":{}, "parentReference":ref._prop_dict, "lastModifiedDateTime": "2015-07-09T22:22:53.99Z"}

        item = Item();
        item._prop_dict = response

        assert isinstance(item.folder, Folder)
        assert item.name == self.name
        assert isinstance(item.parent_reference, ItemReference)
        assert item.parent_reference.id == self.id
        assert isinstance(item.last_modified_date_time, datetime)
        assert item.last_modified_date_time.isoformat()+"Z" == "2015-07-09T22:22:53.990000Z"

        response = {"name":self.name, "folder":{}, "parentReference":ref._prop_dict, "lastModifiedDateTime": "2015-07-09T22:22:53Z"}
        item._prop_dict = response
github OneDrive / onedrive-sdk-python / testonedrivesdk / test_requests.py View on Github external
Test that polling in the background actually functions as it should and polls
        on a seperate thread.
        """
        response = HttpResponse(301, {"Location": "statusLocation"}, "")
        instance_http = MockHttpProvider.return_value
        instance_http.send.return_value = response

        instance_auth = MockAuthProvider.return_value
        instance_auth.authenticate.return_value = "blah"
        instance_auth.authenticate_request.return_value = None

        http_provider = onedrivesdk.HttpProvider()
        auth_provider = onedrivesdk.AuthProvider()
        client = onedrivesdk.OneDriveClient("onedriveurl/", http_provider, auth_provider)

        ref = ItemReference()
        ref.id = "testing!id"
        mock = Mock()

        copy_operation = client.drives["me"].items["testitem!id"].copy(parent_reference=ref, name="newName").request().post()
        
        response = HttpResponse(200, None, json.dumps({"operation":"copy", "percentageComplete":0, "status": "In progress"}))
        instance_http.send.return_value = response
        
        time.sleep(0.2)

        assert copy_operation.item is None

        response = HttpResponse(200, None, json.dumps({"id" : "testitem!id", "name": "newName"}))
        instance_http.send.return_value = response

        time.sleep(0.1)
github OneDrive / onedrive-sdk-python / testonedrivesdk / test_models.py View on Github external
def test_serialization(self):
        """
        Test the serialization of the dict-backed models, seeing that
        the correct objects are returned when called
        """
        ref = ItemReference();
        ref._prop_dict = {"id": self.id}

        response = {"name":self.name, "folder":{}, "parentReference":ref._prop_dict, "lastModifiedDateTime": "2015-07-09T22:22:53.993000Z"}

        item = Item();
        item._prop_dict = response

        assert isinstance(item.folder, Folder)
        assert item.name == self.name
        assert isinstance(item.parent_reference, ItemReference)
        assert item.parent_reference.id == self.id
        assert isinstance(item.last_modified_date_time, datetime)
        assert item.last_modified_date_time.isoformat()+"Z" == response["lastModifiedDateTime"]
github OneDrive / onedrive-sdk-python / testonedrivesdk / test_models.py View on Github external
def test_serialization(self):
        """
        Test the serialization of the dict-backed models, seeing that
        the correct objects are returned when called
        """
        ref = ItemReference();
        ref._prop_dict = {"id": self.id}

        response = {"name":self.name, "folder":{}, "parentReference":ref._prop_dict, "lastModifiedDateTime": "2015-07-09T22:22:53.993000Z"}

        item = Item();
        item._prop_dict = response

        assert isinstance(item.folder, Folder)
        assert item.name == self.name
        assert isinstance(item.parent_reference, ItemReference)
        assert item.parent_reference.id == self.id
        assert isinstance(item.last_modified_date_time, datetime)
        assert item.last_modified_date_time.isoformat()+"Z" == response["lastModifiedDateTime"]
github OneDrive / onedrive-sdk-python / testonedrivesdk / test_requests.py View on Github external
def test_method_body_format(self, MockHttpProvider, MockAuthProvider):
        """
        Test that the parameters are correctly entered into the body of the message
        of methods that require this
        """
        http_provider = onedrivesdk.HttpProvider()
        auth_provider = onedrivesdk.AuthProvider()
        client = onedrivesdk.OneDriveClient("onedriveurl/", http_provider, auth_provider)

        ref = ItemReference()
        ref.id = "testing!id"

        copy_request = client.drives["me"].items["testitem!id"].copy(parent_reference=ref, name="newName").request()
        assert copy_request.request_url == "onedriveurl/drives/me/items/testitem!id/action.copy"

        expected_dict = {"parentReference": {"id":"testing!id"}, "name":"newName"}
        assert all(item in copy_request.body_options.items() for item in expected_dict.items())