diff --git a/src/pieces_os_client/wrapper/basic_identifier/asset.py b/src/pieces_os_client/wrapper/basic_identifier/asset.py index 864d3f08..dbaf851c 100644 --- a/src/pieces_os_client/wrapper/basic_identifier/asset.py +++ b/src/pieces_os_client/wrapper/basic_identifier/asset.py @@ -81,9 +81,6 @@ def raw_content(self, content: str): Args: content: The new content to be set. - - Raises: - NotImplemented: If the asset is an image. """ format_api = AssetSnapshot.pieces_client.format_api if self.is_image: @@ -95,6 +92,9 @@ def raw_content(self, content: str): original.fragment.string.raw = content elif original.file and original.file.string and original.file.string.raw: original.file.string.raw = content + elif original.file and original.file.bytes and original.file.bytes.raw: + original.file.bytes.raw = list(content.encode('utf-8')) + format_api.format_update_value(transferable=False, format=original) @property diff --git a/tests/test_basic_asset.py b/tests/test_basic_asset.py index c27c8069..cd92cc20 100644 --- a/tests/test_basic_asset.py +++ b/tests/test_basic_asset.py @@ -135,7 +135,7 @@ def test_share_with_asset(self): mock_user_profile = MagicMock() mock_user_profile.allocation = True - with patch('pieces_os_client.wrapper.basic_identifier.BasicUser.user_profile', mock_user_profile), \ + with patch('pieces_os_client.wrapper.streamed_identifiers.assets_snapshot.AssetSnapshot.pieces_client.user.user_profile', mock_user_profile), \ patch.object(AssetSnapshot.pieces_client.linkfy_api, 'linkify') as mock_linkify: mock_linkify.return_value = "shareable_link" @@ -155,7 +155,7 @@ def test_share_with_seed(self): mock_user_profile = MagicMock() mock_user_profile.allocation = True - with patch('pieces_os_client.wrapper.basic_identifier.BasicUser.user_profile', mock_user_profile), \ + with patch('pieces_os_client.wrapper.streamed_identifiers.assets_snapshot.AssetSnapshot.pieces_client.user.user_profile', mock_user_profile), \ patch.object(AssetSnapshot.pieces_client.linkfy_api, 'linkify') as mock_linkify: mock_linkify.return_value = "shareable_link" @@ -173,7 +173,7 @@ def test_share_with_seed(self): def test_share_without_user_profile(self): basic_asset = BasicAsset("test_asset_id") - with patch('pieces_os_client.wrapper.basic_identifier.BasicUser.user_profile', None): + with patch('pieces_os_client.wrapper.streamed_identifiers.assets_snapshot.AssetSnapshot.pieces_client.user.user_profile', None): with pytest.raises(PermissionError, match="You need to be logged in to generate a shareable link"): basic_asset._share(asset=basic_asset.asset) @@ -182,7 +182,7 @@ def test_share_without_allocation(self): mock_user_profile = MagicMock() mock_user_profile.allocation = False - with patch('pieces_os_client.wrapper.basic_identifier.BasicUser.user_profile', mock_user_profile): + with patch('pieces_os_client.wrapper.streamed_identifiers.assets_snapshot.AssetSnapshot.pieces_client.user.user_profile', mock_user_profile): with pytest.raises(PermissionError, match="You need to connect to the cloud to generate a shareable link"): basic_asset._share(asset=basic_asset.asset) diff --git a/tests/test_basic_user.py b/tests/test_basic_user.py index 246a3918..26fc48db 100644 --- a/tests/test_basic_user.py +++ b/tests/test_basic_user.py @@ -23,7 +23,7 @@ def test_login_and_connect(self): def test_logout(self): self.basic_user.logout() - self.mock_pieces_client.api_client.os_api.sign_out_of_os.assert_called_once() + self.mock_pieces_client.os_api.sign_out_of_os.assert_called_once() def test_connect(self): self.basic_user.connect() @@ -37,7 +37,7 @@ def test_connect_without_login(self): def test_disconnect(self): self.mock_user_profile.allocation = MagicMock() self.basic_user.disconnect() - self.mock_pieces_client.api_client.allocations_api.allocations_disconnect_cloud.assert_called_once_with(self.mock_user_profile.allocation) + self.mock_pieces_client.allocations_api.allocations_disconnect_cloud.assert_called_once_with(self.mock_user_profile.allocation) def test_disconnect_without_login(self): self.basic_user.user_profile = None