示例#1
0
    def test_create_staticapp_with_standard_sku(self):
        from azure.mgmt.web.models import StaticSiteARMResource, StaticSiteBuildProperties, SkuDescription
        self.mock_cmd.get_models.return_value = StaticSiteARMResource, StaticSiteBuildProperties, SkuDescription

        create_staticsites(self.mock_cmd,
                           self.rg1,
                           self.name1,
                           self.location1,
                           self.source1,
                           self.branch1,
                           self.token1,
                           sku='standard')

        self.staticapp_client.create_or_update_static_site.assert_called_once()
        arg_list = self.staticapp_client.create_or_update_static_site.call_args.kwargs
        self.assertEqual('Standard', arg_list["static_site_envelope"].sku.name)
    def test_create_staticapp_missing_token(self):
        app_location = './src'
        api_location = './api/'
        app_artifact_location = '/.git/'
        tags = {'key1': 'value1'}

        with self.assertRaises(CLIError):
            create_staticsites(self.mock_cmd,
                               self.rg1,
                               self.name1,
                               self.location1,
                               self.source1,
                               self.branch1,
                               app_location=app_location,
                               api_location=api_location,
                               app_artifact_location=app_artifact_location,
                               tags=tags)
    def test_create_staticapp(self):
        from azure.mgmt.web.models import StaticSiteARMResource, StaticSiteBuildProperties, SkuDescription
        self.mock_cmd.get_models.return_value = StaticSiteARMResource, StaticSiteBuildProperties, SkuDescription
        app_location = './src'
        api_location = './api/'
        output_location = '/.git/'
        tags = {'key1': 'value1'}

        create_staticsites(self.mock_cmd,
                           self.rg1,
                           self.name1,
                           self.location1,
                           self.source1,
                           self.branch1,
                           self.token1,
                           app_location=app_location,
                           api_location=api_location,
                           output_location=output_location,
                           tags=tags)

        self.staticapp_client.create_or_update_static_site.assert_called_once()
        arg_list = self.staticapp_client.create_or_update_static_site.call_args[
            1]
        self.assertEqual(self.name1, arg_list["name"])
        self.assertEqual(self.rg1, arg_list["resource_group_name"])
        self.assertEqual(self.location1,
                         arg_list["static_site_envelope"].location)
        self.assertEqual(self.source1,
                         arg_list["static_site_envelope"].repository_url)
        self.assertEqual(self.branch1, arg_list["static_site_envelope"].branch)
        self.assertEqual(tags, arg_list["static_site_envelope"].tags)
        self.assertEqual('Free', arg_list["static_site_envelope"].sku.name)
        self.assertEqual(
            app_location,
            arg_list["static_site_envelope"].build_properties.app_location)
        self.assertEqual(
            api_location,
            arg_list["static_site_envelope"].build_properties.api_location)
        self.assertEqual(
            output_location, arg_list["static_site_envelope"].build_properties.
            app_artifact_location)