Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/core/tests/test_converters.py
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | def test_content_for_storage_path(self): | ||||
tmpfile = tmpfile_with_content(self.tmpdir.name, data) | tmpfile = tmpfile_with_content(self.tmpdir.name, data) | ||||
obj = Content.from_file(path=os.fsdecode(tmpfile), | obj = Content.from_file(path=os.fsdecode(tmpfile), | ||||
save_path=True).get_data() | save_path=True).get_data() | ||||
expected_content = obj.copy() | expected_content = obj.copy() | ||||
expected_content['data'] = data | expected_content['data'] = data | ||||
expected_content['status'] = 'visible' | expected_content['status'] = 'visible' | ||||
del expected_content['path'] | |||||
del expected_content['perms'] | |||||
# when | # when | ||||
content = converters.content_for_storage(obj) | content = converters.content_for_storage(obj) | ||||
# then | # then | ||||
self.assertEqual(content, expected_content) | self.assertEqual(content, expected_content) | ||||
def test_content_for_storage_data(self): | def test_content_for_storage_data(self): | ||||
# given | # given | ||||
data = b'temp file for testing content storage conversion' | data = b'temp file for testing content storage conversion' | ||||
obj = Content.from_bytes(data=data, mode=0o100644).get_data() | obj = Content.from_bytes(data=data, mode=0o100644).get_data() | ||||
expected_content = obj.copy() | expected_content = obj.copy() | ||||
expected_content['status'] = 'visible' | expected_content['status'] = 'visible' | ||||
del expected_content['perms'] | |||||
# when | # when | ||||
content = converters.content_for_storage(obj) | content = converters.content_for_storage(obj) | ||||
# then | # then | ||||
self.assertEqual(content, expected_content) | self.assertEqual(content, expected_content) | ||||
def test_content_for_storage_too_long(self): | def test_content_for_storage_too_long(self): | ||||
Show All 24 Lines |