示例#1
0
    def test_botservice_prepare_deploy_csharp_no_proj_file(self):
        code_dir = None
        language = 'Csharp'
        proj_file_path = None

        try:
            prepare_webapp_deploy(language, code_dir, proj_file_path)
            raise Exception("'az bot prepare-publish --lang Csharp' should have failed with no --proj-file-path")
        except CLIError as cli_error:
            assert cli_error.__str__() == '--proj-file-path must be provided if language is Csharp'
示例#2
0
    def test_botservice_prepare_deploy_typescript_should_fail_with_proj_file_path(self):
        code_dir = None
        language = 'Typescript'
        proj_file_path = 'node_bot/test.csproj'

        try:
            prepare_webapp_deploy(language, code_dir, proj_file_path)
            raise Exception("'az bot prepare-publish --lang Typescript' should have failed with --proj-file-path")
        except CLIError as cli_error:
            assert cli_error.__str__() == '--proj-file-path should not be passed in if language is not Csharp'
示例#3
0
    def test_botservice_prepare_deploy_typescript(self):
        code_dir = 'node_bot_typescript'
        language = 'Typescript'
        proj_file_path = None

        if os.path.exists(code_dir):
            # clean up the folder
            shutil.rmtree(code_dir)
        os.mkdir(code_dir)
        prepare_webapp_deploy(language, code_dir, proj_file_path)
        assert os.path.exists(os.path.join(code_dir, 'web.config'))
        shutil.rmtree(code_dir)
示例#4
0
    def test_botservice_prepare_deploy_should_fail_if_code_dir_doesnt_exist(self):
        code_dir = 'does_not_exist'
        language = 'Javascript'
        proj_file_path = None

        try:
            prepare_webapp_deploy(language, code_dir, proj_file_path)
            raise Exception("'az bot prepare-publish' should have failed with nonexistent --code-dir value")
        except CLIError as cli_error:
            print(cli_error.__str__())
            assert cli_error.__str__() == 'Provided --code-dir value (does_not_exist) does not exist'
        except Exception as error:
            raise error
示例#5
0
    def test_botservice_prepare_deploy_csharp_preserve_filename_casing(self):
        code_dir = 'csharp_bot_success_casing'
        language = 'Csharp'
        proj_file_path = 'Azure_azure-cli_11390.csproj'

        if os.path.exists(code_dir):
            # clean up the folder
            shutil.rmtree(code_dir)
        os.mkdir(code_dir)
        open(os.path.join(code_dir, proj_file_path), 'w')

        prepare_webapp_deploy(language, code_dir, proj_file_path)
        assert os.path.exists(os.path.join(code_dir, '.deployment'))
        with open(os.path.join(code_dir, '.deployment')) as d:
            assert d.readline() == '[config]\n'
            assert d.readline() == 'SCM_SCRIPT_GENERATOR_ARGS=--aspNetCore "{0}"\n'.format(proj_file_path)
        shutil.rmtree(code_dir)
示例#6
0
    def test_botservice_prepare_deploy_javascript_fail_if_web_config_exists(self):
        code_dir = 'node_bot_web_config'
        language = 'Javascript'
        proj_file_path = None

        if os.path.exists(code_dir):
            # clean up the folder
            shutil.rmtree(code_dir)
        os.mkdir(code_dir)
        open(os.path.join(code_dir, 'web.config'), 'w')

        try:
            prepare_webapp_deploy(language, code_dir, proj_file_path)
            shutil.rmtree(code_dir)
        except CLIError as cli_error:
            shutil.rmtree(code_dir)
            assert cli_error.__str__() == 'web.config found in node_bot_web_config\nPlease delete this web.config before ' \
                                          'calling "az bot prepare-deploy"'
        except Exception as error:
            shutil.rmtree(code_dir)
            raise error
示例#7
0
    def test_botservice_prepare_deploy_csharp_fail_if_deployment_file_exists(self):
        code_dir = 'csharp_bot_deployment'
        language = 'Csharp'
        proj_file_path = 'test.csproj'

        if os.path.exists(code_dir):
            # clean up the folder
            shutil.rmtree(code_dir)
        os.mkdir(code_dir)
        open(os.path.join(code_dir, proj_file_path), 'w')
        open(os.path.join(code_dir, '.deployment'), 'w')

        try:
            prepare_webapp_deploy(language, code_dir, proj_file_path)
            shutil.rmtree(code_dir)
        except CLIError as cli_error:
            shutil.rmtree(code_dir)
            assert cli_error.__str__() == '.deployment found in csharp_bot_deployment\nPlease delete this .deployment before ' \
                                          'calling "az bot prepare-deploy"'
        except Exception as error:
            shutil.rmtree(code_dir)
            raise error