本文整理汇总了Python中pyuploadcare.api_resources.FileGroup类的典型用法代码示例。如果您正苦于以下问题:Python FileGroup类的具体用法?Python FileGroup怎么用?Python FileGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileGroup类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileGroupDateMethodsTest
class FileGroupDateMethodsTest(unittest.TestCase):
def setUp(self):
self.group = FileGroup('0513dda0-582f-447d-846f-096e5df9e2bb~2')
def test_datetime_stored_is_none(self):
self.group._info_cache = {'datetime_stored': ''}
self.assertIsNone(self.group.datetime_stored())
def test_datetime_stored_is_utc(self):
self.group._info_cache = {'datetime_stored': '2013-04-03T12:01:28.714Z'}
expected_datetime = datetime.datetime(
year=2013, month=4, day=3, hour=12, minute=1, second=28,
microsecond=714000, tzinfo=tzutc())
self.assertEqual(self.group.datetime_stored(), expected_datetime)
def test_datetime_created_is_none(self):
self.group._info_cache = {'datetime_created': ''}
self.assertIsNone(self.group.datetime_created())
def test_datetime_created_is_utc(self):
self.group._info_cache = {'datetime_created': '2013-04-03T12:01:28.714Z'}
expected_datetime = datetime.datetime(
year=2013, month=4, day=3, hour=12, minute=1, second=28,
microsecond=714000, tzinfo=tzutc())
self.assertEqual(self.group.datetime_created(), expected_datetime)
示例2: test_do_not_store_twice
def test_do_not_store_twice(self, request):
group = FileGroup(cdn_url_or_group_id="0513dda0-582f-447d-846f-096e5df9e2bb~2")
# GET /api/groups/{group_id}/
request.return_value = MockResponse(status=200, data=b'{"datetime_stored": "2013-04-03T12:01:28.714Z"}')
group.store()
group.store()
self.assertEqual(request.call_count, 1)
示例3: test_successful_store
def test_successful_store(self, request):
group = FileGroup(cdn_url_or_group_id="0513dda0-582f-447d-846f-096e5df9e2bb~2")
group._info_cache = {"datetime_stored": None}
# PUT /api/groups/{group_id}/storage/
request.return_value = MockResponse(status=200, data=b'{"datetime_stored": "2013-04-03T12:01:28.714Z"}')
group.store()
self.assertEqual(request.call_count, 1)
示例4: FileGroupAsContainerTypeTest
class FileGroupAsContainerTypeTest(unittest.TestCase):
@patch('requests.sessions.Session.request', autospec=True)
def setUp(self, request):
request.return_value = MockResponse(
status=200,
data=api_response_from_file('group_files.json')
)
self.group = FileGroup(
cdn_url_or_group_id='0513dda0-582f-447d-846f-096e5df9e2bb~2'
)
# It is necessary to avoid api call in tests below.
self.group.update_info()
def test_positive_index(self):
self.assertIsInstance(self.group[0], File)
def test_negative_index(self):
self.assertIsNone(self.group[-1])
def test_index_is_out_of_range(self):
with self.assertRaises(IndexError):
self.group[2]
def test_non_int_index(self):
with self.assertRaises(TypeError):
self.group['a']
def test_iteration(self):
[file_ for file_ in self.group]
def test_slice_is_not_supported(self):
with self.assertRaises(TypeError):
self.group[0:99]
def test_len(self):
self.assertEqual(len(self.group), 2)
def test_immutability(self):
with self.assertRaises(TypeError):
self.group[0] = 123
示例5: setUp
def setUp(self, request):
request.return_value = MockResponse(
status=200,
data=api_response_from_file('group_files.json')
)
self.group = FileGroup(
cdn_url_or_group_id='0513dda0-582f-447d-846f-096e5df9e2bb~2'
)
# It is necessary to avoid api call in tests below.
self.group.update_info()
示例6: test_group_successfully_created
def test_group_successfully_created(self, request):
json_response = b"""{
"id": "0513dda0-582f-447d-846f-096e5df9e2bb~1",
"files_count": 1,
"files": [
{"uuid": "0cea5a61-f976-47d9-815a-e787f52aeba1"}
]
}
"""
request.return_value = MockResponse(status=200, data=json_response)
files = (File("0cea5a61-f976-47d9-815a-e787f52aeba1"),)
group = FileGroup.create(files)
self.assertIsInstance(group, FileGroup)
self.assertEqual(len(group), 1)
self.assertEqual(group[0].uuid, "0cea5a61-f976-47d9-815a-e787f52aeba1")
示例7: create_file_group
def create_file_group(files_qty=1):
files = [upload_tmp_txt_file() for file_ in range(files_qty)]
group = FileGroup.create(files)
return group
示例8: test_successful_create
def test_successful_create(self):
files = [
upload_tmp_txt_file(content='пока'),
]
group = FileGroup.create(files)
self.assertIsInstance(group, FileGroup)
示例9: create_group
def create_group(arg_namespace):
files = [File(uuid) for uuid in arg_namespace.paths]
group = FileGroup.create(files)
pprint(group.info())