當前位置: 首頁>>代碼示例>>Python>>正文


Python api_resources.FileGroup類代碼示例

本文整理匯總了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)
開發者ID:vishalbandre,項目名稱:pyuploadcare,代碼行數:26,代碼來源:test_api_resources.py

示例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)
開發者ID:uploadcare,項目名稱:pyuploadcare,代碼行數:8,代碼來源:test_api_resources.py

示例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)
開發者ID:uploadcare,項目名稱:pyuploadcare,代碼行數:8,代碼來源:test_api_resources.py

示例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
開發者ID:vishalbandre,項目名稱:pyuploadcare,代碼行數:42,代碼來源:test_api_resources.py

示例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()
開發者ID:vishalbandre,項目名稱:pyuploadcare,代碼行數:11,代碼來源:test_api_resources.py

示例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")
開發者ID:uploadcare,項目名稱:pyuploadcare,代碼行數:17,代碼來源:test_api_resources.py

示例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
開發者ID:uploadcare,項目名稱:pyuploadcare,代碼行數:4,代碼來源:utils.py

示例8: test_successful_create

 def test_successful_create(self):
     files = [
         upload_tmp_txt_file(content='пока'),
     ]
     group = FileGroup.create(files)
     self.assertIsInstance(group, FileGroup)
開發者ID:un33k,項目名稱:pyuploadcare,代碼行數:6,代碼來源:test_api_resources.py

示例9: create_group

def create_group(arg_namespace):
    files = [File(uuid) for uuid in arg_namespace.paths]
    group = FileGroup.create(files)
    pprint(group.info())
開發者ID:uploadcare,項目名稱:pyuploadcare,代碼行數:4,代碼來源:__init__.py


注:本文中的pyuploadcare.api_resources.FileGroup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。