Skip to content

Commit

Permalink
Merge pull request #69 from pieces-app/fix-image
Browse files Browse the repository at this point in the history
Fix image
  • Loading branch information
bishoy-at-pieces authored Sep 9, 2024
2 parents b5687ce + 3175792 commit 8ee7dda
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/pieces_os_client/wrapper/basic_identifier/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/test_basic_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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)

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_basic_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 8ee7dda

Please sign in to comment.