Skip to content

Commit

Permalink
ZO-4267: move and copy tests for blobs (gcs bucket) in postgresql con…
Browse files Browse the repository at this point in the history
…nector
  • Loading branch information
stollero committed Feb 29, 2024
1 parent 69f8d8b commit 9d45716
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions core/src/zeit/connector/tests/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,34 @@ def test_search_for_uuid_uses_indexed_column(self):
unique_id, uuid = next(result)
self.assertEqual(res.id, unique_id)
self.assertEqual(props.id, uuid)

def test_copy_duplicates_gcs_blob(self):
source = self.get_resource('foo', b'mybody')
source.type = 'file'
target = self.get_resource('bar')
self.connector.add(source)
self.connector.copy(source.id, target.id)

source_props = self.connector._get_properties(source.id)
source_blob = self.connector.bucket.blob(source_props.id)

target_props = self.connector._get_properties(target.id)
target_blob = self.connector.bucket.blob(target_props.id)

self.assertNotEqual(source_props.id, target_props.id)
self.assertNotEqual(source_blob, target_blob)
self.assertEqual(source_props.type, target_props.type)
self.assertEqual(source_blob.download_as_bytes(), target_blob.download_as_bytes())

def test_move_does_not_affect_gcs_blob(self):
source = self.get_resource('foo', b'mybody')
source.type = 'file'
target = self.get_resource('bar')
self.connector.add(source)
source_props = self.connector._get_properties(source.id)
source_blob = self.connector.bucket.blob(source_props.id)
self.connector.move(source.id, target.id)
target_props = self.connector._get_properties(target.id)
target_blob = self.connector.bucket.blob(target_props.id)
self.assertEqual(source_props.id, target_props.id)
self.assertEqual(source_blob.name, target_blob.name)

0 comments on commit 9d45716

Please sign in to comment.