Esempio n. 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/')
Esempio n. 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/')
Esempio n. 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/')
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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))
Esempio n. 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')
Esempio n. 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')
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')
Esempio n. 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')
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')
Esempio n. 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')
Esempio n. 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))
Esempio n. 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))
Esempio n. 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')
Esempio n. 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))
Esempio n. 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))
Esempio n. 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')
Esempio n. 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/')
Esempio n. 30
0
    def test_change_secret(self, request):
        request.return_value = MockListResponse()

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

        self.assertEqual(conf.secret, 'demosecretkey')
Esempio n. 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')
Esempio n. 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')
Esempio n. 33
0
    def test_change_secret(self, request):
        request.return_value = MockListResponse()

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

        self.assertEqual(conf.secret, 'demosecretkey')
Esempio n. 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')