示例#1
0
    def test_change_upload_base(self, request):
        request.return_value = MockListResponse()

        main(
            arg_namespace('--upload_base https://uploadcare.com/upload/ list'))

        self.assertEqual(conf.upload_base, 'https://uploadcare.com/upload/')
示例#2
0
    def test_change_api_base(self, request):
        request.return_value = MockListResponse()

        main(
            arg_namespace('--api_base https://uploadcare.com/api/ list_files'))

        self.assertEqual(conf.api_base, 'https://uploadcare.com/api/')
示例#3
0
    def test_change_upload_base(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace(
            '--upload_base https://uploadcare.com/upload/ list_files'))

        self.assertEqual(conf.upload_base, 'https://uploadcare.com/upload/')
示例#4
0
    def test_change_verify_upload_ssl(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('list'))
        self.assertTrue(conf.verify_upload_ssl)

        main(arg_namespace('--no_check_upload_certificate list'))
        self.assertFalse(conf.verify_upload_ssl)
示例#5
0
    def test_change_verify_api_ssl(self, request):
        request.return_value = MockResponse(status=200)

        main(arg_namespace('list'))
        self.assertTrue(conf.verify_api_ssl)

        main(arg_namespace('--no_check_api_certificate list'))
        self.assertFalse(conf.verify_api_ssl)
示例#6
0
    def test_change_verify_upload_ssl(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('list'))
        self.assertTrue(conf.verify_upload_ssl)

        main(arg_namespace('--no_check_upload_certificate list'))
        self.assertFalse(conf.verify_upload_ssl)
    def test_change_verify_api_ssl(self, request):
        request.return_value = MockResponse(status=200)

        main(arg_namespace('list'))
        self.assertTrue(conf.verify_api_ssl)

        main(arg_namespace('--no_check_api_certificate list'))
        self.assertFalse(conf.verify_api_ssl)
示例#8
0
    def test_load_verify_api_ssl_false_value_from_config(self, request):
        request.return_value = MockResponse(status=200)

        self.tmp_config_file.write('[ucare]\n' 'verify_api_ssl = false')
        self.tmp_config_file.close()

        main(arg_namespace('list'), [self.tmp_config_file.name])

        self.assertFalse(conf.verify_api_ssl)
示例#9
0
    def test_load_verify_api_ssl_true_value_from_config(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write('[ucare]\n' 'verify_api_ssl = true')
        self.tmp_config_file.close()

        main(arg_namespace('list'), [self.tmp_config_file.name])

        self.assertTrue(conf.verify_api_ssl)
示例#10
0
    def test_calling_without_params(self, GroupList, pprint):
        instance = self.make_group_list(GroupList)
        main(arg_namespace('list_groups'))

        GroupList.assert_called_once_with(starting_point=None,
                                          ordering=None,
                                          limit=100,
                                          request_limit=100)
        pprint.assert_called_once_with(list(instance))
示例#11
0
    def test_redefine_config_pub_key_by_args(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write('[ucare]\n' 'pub_key = demopublickey')
        self.tmp_config_file.close()

        main(arg_namespace('--pub_key pub list'), [self.tmp_config_file.name])

        self.assertEqual(conf.pub_key, 'pub')
示例#12
0
    def test_use_pub_key_from_config_file(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write('[ucare]\n' 'pub_key = demopublickey')
        self.tmp_config_file.close()

        main(arg_namespace('list'), [self.tmp_config_file.name])

        self.assertEqual(conf.pub_key, 'demopublickey')
示例#13
0
    def test_redefine_config_verify_api_ssl_by_args(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write('[ucare]\n' 'verify_api_ssl = true')
        self.tmp_config_file.close()

        main(arg_namespace('--no_check_api_certificate list'),
             [self.tmp_config_file.name])

        self.assertFalse(conf.verify_api_ssl)
示例#14
0
    def test_calling_without_params(self, GroupList, pprint):
        instance = self.make_group_list(GroupList)
        main(arg_namespace('list_groups'))

        GroupList.assert_called_once_with(
            starting_point=None,
            ordering=None,
            limit=100,
            request_limit=100
        )
        pprint.assert_called_once_with(list(instance))
    def test_load_verify_api_ssl_false_value_from_config(self, request):
        request.return_value = MockResponse(status=200)

        self.tmp_config_file.write(
            '[ucare]\n'
            'verify_api_ssl = false'
        )
        self.tmp_config_file.close()

        main(arg_namespace('list'), [self.tmp_config_file.name])

        self.assertFalse(conf.verify_api_ssl)
示例#16
0
    def test_use_pub_key_from_config_file(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write(
            '[ucare]\n'
            'pub_key = demopublickey'
        )
        self.tmp_config_file.close()

        main(arg_namespace('list'), [self.tmp_config_file.name])

        self.assertEqual(conf.pub_key, 'demopublickey')
示例#17
0
    def test_redefine_config_pub_key_by_args(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write(
            '[ucare]\n'
            'pub_key = demopublickey'
        )
        self.tmp_config_file.close()

        main(arg_namespace('--pub_key pub list'), [self.tmp_config_file.name])

        self.assertEqual(conf.pub_key, 'pub')
示例#18
0
    def test_load_verify_api_ssl_true_value_from_config(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write(
            '[ucare]\n'
            'verify_api_ssl = true'
        )
        self.tmp_config_file.close()

        main(arg_namespace('list'), [self.tmp_config_file.name])

        self.assertTrue(conf.verify_api_ssl)
示例#19
0
    def test_redefine_config_verify_api_ssl_by_args(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write(
            '[ucare]\n'
            'verify_api_ssl = true'
        )
        self.tmp_config_file.close()

        main(arg_namespace('--no_check_api_certificate list'),
             [self.tmp_config_file.name])

        self.assertFalse(conf.verify_api_ssl)
示例#20
0
    def test_use_available_pub_key_from_config_files(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write('[ucare]\n' 'pub_key = demopublickey')
        self.tmp_config_file.close()

        second_tmp_conf_file = NamedTemporaryFile(mode='w+t', delete=False)
        second_tmp_conf_file.write('[ucare]\n' 'secret = demosecretkey')
        second_tmp_conf_file.close()

        main(arg_namespace('list'),
             [self.tmp_config_file.name, second_tmp_conf_file.name])

        self.assertEqual(conf.pub_key, 'demopublickey')
示例#21
0
    def test_redefine_pub_key_by_second_config_file(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write('[ucare]\n' 'pub_key = demopublickey')
        self.tmp_config_file.close()

        second_tmp_conf_file = NamedTemporaryFile(mode='w+t', delete=False)
        second_tmp_conf_file.write('[ucare]\n'
                                   'pub_key = demopublickey_modified')
        second_tmp_conf_file.close()

        main(arg_namespace('list_files'),
             [self.tmp_config_file.name, second_tmp_conf_file.name])

        self.assertEqual(conf.pub_key, 'demopublickey_modified')
示例#22
0
    def test_calling_with_params(self, GroupList, pprint):
        instance = self.make_group_list(GroupList)
        main(
            arg_namespace('list_groups '
                          '--starting_point=2015-10-21 '
                          '--ordering=-datetime_created '
                          '--limit 10 '
                          '--request_limit 5'))

        GroupList.assert_called_once_with(
            starting_point=parser.parse('2015-10-21'),
            ordering='-datetime_created',
            limit=10,
            request_limit=5)
        pprint.assert_called_once_with(list(instance))
示例#23
0
    def test_calling_with_params(self, GroupList, pprint):
        instance = self.make_group_list(GroupList)
        main(arg_namespace('list_groups '
                           '--starting_point=2015-10-21 '
                           '--ordering=-datetime_created '
                           '--limit 10 '
                           '--request_limit 5'))

        GroupList.assert_called_once_with(
            starting_point=parser.parse('2015-10-21'),
            ordering='-datetime_created',
            limit=10,
            request_limit=5
        )
        pprint.assert_called_once_with(list(instance))
示例#24
0
    def test_use_available_pub_key_from_config_files(self, request):
        request.return_value = MockListResponse()

        self.tmp_config_file.write(
            '[ucare]\n'
            'pub_key = demopublickey'
        )
        self.tmp_config_file.close()

        second_tmp_conf_file = NamedTemporaryFile(mode='w+t', delete=False)
        second_tmp_conf_file.write(
            '[ucare]\n'
            'secret = demosecretkey'
        )
        second_tmp_conf_file.close()

        main(arg_namespace('list'),
             [self.tmp_config_file.name, second_tmp_conf_file.name])

        self.assertEqual(conf.pub_key, 'demopublickey')
    def test_redefine_pub_key_by_second_config_file(self, request):
        request.return_value = MockResponse(status=200)

        self.tmp_config_file.write(
            '[ucare]\n'
            'pub_key = demopublickey'
        )
        self.tmp_config_file.close()

        second_tmp_conf_file = NamedTemporaryFile(mode='w+t', delete=False)
        second_tmp_conf_file.write(
            '[ucare]\n'
            'pub_key = demopublickey_modified'
        )
        second_tmp_conf_file.close()

        main(arg_namespace('list'),
             [self.tmp_config_file.name, second_tmp_conf_file.name])

        self.assertEqual(conf.pub_key, 'demopublickey_modified')
示例#26
0
 def test_empty_result(self, GroupList, pprint):
     instance = self.make_group_list(GroupList, list_groups=[])
     main(arg_namespace('list_groups'))
     self.assertTrue(GroupList.called)
     pprint.assert_called_once_with(list(instance))
示例#27
0
 def test_empty_result(self, GroupList, pprint):
     instance = self.make_group_list(GroupList, list_groups=[])
     main(arg_namespace('list_groups'))
     self.assertTrue(GroupList.called)
     pprint.assert_called_once_with(list(instance))
示例#28
0
    def test_change_api_version(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('--api_version 0.777 list'))

        self.assertEqual(conf.api_version, '0.777')
示例#29
0
    def test_change_api_base(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('--api_base https://uploadcare.com/api/ list'))

        self.assertEqual(conf.api_base, 'https://uploadcare.com/api/')
示例#30
0
    def test_change_secret(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('--secret demosecretkey list'))

        self.assertEqual(conf.secret, 'demosecretkey')
示例#31
0
    def test_change_pub_key(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('--pub_key demopublickey list'))

        self.assertEqual(conf.pub_key, 'demopublickey')
示例#32
0
    def test_change_pub_key(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('--pub_key demopublickey list'))

        self.assertEqual(conf.pub_key, 'demopublickey')
示例#33
0
    def test_change_secret(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('--secret demosecretkey list'))

        self.assertEqual(conf.secret, 'demosecretkey')
示例#34
0
    def test_change_api_version(self, request):
        request.return_value = MockListResponse()

        main(arg_namespace('--api_version 0.777 list'))

        self.assertEqual(conf.api_version, '0.777')