예제 #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)
예제 #7
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)
예제 #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))
예제 #15
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)
예제 #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')
예제 #25
0
    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')