Example #1
0
    def test_create_upload_area_no_config_display_error(self):
        # given
        args = ['create', 'testUploadArea']

        # when
        success, msg = CmdCreate(None, parse_args(args)).run()

        # then
        self.assertFalse(success)
        self.assertEqual(msg, 'You need configure your profile first')
Example #2
0
    def test_user_create_upload_area_has_valid_config(self):
        # given
        self.aws_mock.is_user = True

        args = ['create', 'testUploadArea']

        # when
        success, msg = CmdCreate(self.aws_mock, parse_args(args)).run()

        # then
        self.assertFalse(success)
        self.assertEqual(msg, 'You don\'t have permission to use this command')
Example #3
0
    def test_admin_create_upload_area_has_exception(self, uuid):
        # given
        uuid.return_value = 'uuid'

        args = ['create', 'testUploadArea']
        self.client.put_object.side_effect = Mock(
            side_effect=Exception('Test'))

        # when
        success, msg = CmdCreate(self.aws_mock, parse_args(args)).run()

        # then
        self.assertFalse(success)
Example #4
0
    def test_admin_create_upload_area_no_name(self):
        # given
        args = ['create']

        # when
        with self.assertRaises(SystemExit) as error:
            parsed_args = parse_args(args)
            success, msg = CmdCreate(self.aws_mock, parsed_args).run()
            self.assertFalse(parsed_args)
            self.assertFalse(success)
            self.assertFalse(msg)

        self.assertEqual(error.exception.code, 2)
Example #5
0
    def test_admin_create_upload_area(self, uuid):
        # given
        uuid.return_value = 'uuid'

        args = ['create', 'testUploadArea']

        # when
        success, msg = CmdCreate(self.aws_mock, parse_args(args)).run()

        # then
        self.assertTrue(success)

        metadata = {'name': 'testUploadArea', 'perms': 'ux'}
        self.client.put_object.assert_called_once_with(Bucket='bucket-name',
                                                       Key='uuid/',
                                                       Metadata=metadata)
Example #6
0
    def execute(self, args):
        if args.command == 'create':
            success, msg = CmdCreate(self.aws, args).run()
            self.exit(success, msg)

        elif args.command == 'select':
            success, msg = CmdSelect(self.aws, args).run()
            self.exit(success, msg)

        elif args.command == 'list':
            success, msg = CmdList(self.aws, args).run()
            self.exit(success, msg)

        elif args.command == 'upload':
            success, msg = CmdUpload(self.aws, args).run()
            self.exit(success, msg)

        elif args.command == 'download':
            success, msg = CmdDownload(self.aws, args).run()
            self.exit(success, msg)

        elif args.command == 'delete':
            success, msg = CmdDelete(self.aws, args).run()
            self.exit(success, msg)