• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python views.CreateApp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tsuru_dashboard.apps.views.CreateApp的典型用法代码示例。如果您正苦于以下问题:Python CreateApp类的具体用法?Python CreateApp怎么用?Python CreateApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CreateApp类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_pools_when_api_returns_pools_in_new_format

 def test_pools_when_api_returns_pools_in_new_format(self, get):
     mocked_response = Mock(status_code=200)
     mocked_response.json.return_value = json.loads('[{"name": "theonepool"}]')
     get.return_value = mocked_response
     view = CreateApp()
     pools = view.pools(self.request)
     self.assertEqual([("", ""), ("theonepool", "theonepool")], pools)
开发者ID:tsuru,项目名称:tsuru-dashboard,代码行数:7,代码来源:test_create_app_view.py


示例2: test_pools_when_api_returns_pools_in_older_format

 def test_pools_when_api_returns_pools_in_older_format(self, get):
     mocked_response = Mock(status_code=200)
     mocked_response.json.return_value = json.loads('[{"Name": "dead"}]')
     get.return_value = mocked_response
     view = CreateApp()
     pools = view.pools(self.request)
     self.assertListEqual([("", ""), ("dead", "dead")], pools)
开发者ID:tsuru,项目名称:tsuru-dashboard,代码行数:7,代码来源:test_create_app_view.py


示例3: test_teams_empty

    def test_teams_empty(self, get):
        m = Mock(status_code=204)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {"tsuru_token": "tokentest"}

        view = CreateApp()
        teams = view.teams(request)
        self.assertEqual([("", "")], teams)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:9,代码来源:test_create_app_view.py


示例4: test_pools_empty

    def test_pools_empty(self, get):
        content = u"[]"
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        pools = view.pools(request)
        self.assertListEqual([('', '')], pools)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:11,代码来源:test_create_app_view.py


示例5: test_post_should_split_tags

    def test_post_should_split_tags(self, get):
        data = {"name": "myepe", "platform": "django", "tags": " tag 1 , tag 2, tag 3  ,, , "}
        request = RequestFactory().post("/", data)
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        view.plans = lambda r: ("basic", [("basic", "basic")])
        view.platforms = lambda r: [("django", "django")]
        view.post(request)

        CreateApp.client.apps.create.assert_called_with(name="myepe", platform="django", tag=["tag 1", "tag 2", "tag 3"])
开发者ID:tsuru,项目名称:tsuru-dashboard,代码行数:11,代码来源:test_create_app_view.py


示例6: test_pools_1_0

    def test_pools_1_0(self, get):
        content = u"""[{"Name": "dead"}]"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        pools = view.pools(request)
        self.assertListEqual([("", ""), ('dead', 'dead')], pools)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:11,代码来源:test_create_app_view.py


示例7: test_pools_old_format

    def test_pools_old_format(self, get):
        content = u"""[{"Pools": ["basic", "one"], "Team": "andrews"}]"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        pools = view.pools(request)
        self.assertListEqual([("", ""), ('one', 'one'), ('basic', 'basic')], pools)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:11,代码来源:test_create_app_view.py


示例8: test_plans

    def test_plans(self, get):
        content = u"""[{"name": "plan1"}]"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {"tsuru_token": "tokentest"}

        view = CreateApp()
        plans = view.plans(request)
        self.assertEqual(("", [("", ""), ('plan1', 'plan1')]), plans)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:11,代码来源:test_create_app_view.py


示例9: test_post_should_send_to_tsuru_removing_empty_keys

    def test_post_should_send_to_tsuru_removing_empty_keys(self, get):
        data = {"name": "myepe", "platform": "django", "plan": ""}
        request = RequestFactory().post("/", data)
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        view.plans = lambda r: ("basic", [("basic", "basic")])
        view.platforms = lambda r: [("django", "django")]
        view.post(request)

        CreateApp.client.apps.create.assert_called_with(name="myepe", platform="django")
开发者ID:tsuru,项目名称:tsuru-dashboard,代码行数:11,代码来源:test_create_app_view.py


示例10: test_pools_new_api

    def test_pools_new_api(self, get):
        content = u"""{"pools_by_team": [{"Pools": ["one"], "Team": "admin"}],
            "public_pools": [{"Default": "True", "Public": "True", "Name": "basic", "Teams": []}]}"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {"tsuru_token": "tokentest"}

        view = CreateApp()
        pools = view.pools(request)
        self.assertEqual([("", ""), ('one', 'one'), ('basic', 'basic')], pools)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:12,代码来源:test_create_app_view.py


示例11: test_plans_is_None

    def test_plans_is_None(self, get_mock):
        response_mock = Mock()
        response_mock.json.return_value = None
        get_mock.return_value = response_mock

        data = {"name": "myepe", "platform": "django", "plan": "basic"}
        request = RequestFactory().post("/", data)
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        default, plans = view.plans(request)
        self.assertEqual(default, '')
        self.assertListEqual([('', '')], plans)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:13,代码来源:test_create_app_view.py


示例12: test_post_with_success_should_redirect_to_app_list

    def test_post_with_success_should_redirect_to_app_list(self, get, success):
        data = {"name": "myepe", "platform": "django", "plan": ""}
        request = RequestFactory().post("/", data)
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        view.plans = lambda r: ("basic", [("basic", "basic")])
        view.platforms = lambda r: [("django", "django")]
        response = view.post(request)

        success.assert_called_with(request, u'App was successfully created', fail_silently=True)
        self.assertEquals(302, response.status_code)
        self.assertEquals("/apps/", response.url)
开发者ID:tsuru,项目名称:tsuru-dashboard,代码行数:13,代码来源:test_create_app_view.py


示例13: test_should_use_create_template

    def test_should_use_create_template(self, get):
        content = u"""[{"Name":"python"},{"Name":"ruby"},{"Name":"static"}]"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {}

        view = CreateApp()
        view.plans = lambda r: ("small", [("small", "small")])
        view.teams = lambda r: []
        view.pools = lambda r: []
        response = view.get(request)

        self.assertEqual("apps/create.html", response.template_name)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:15,代码来源:test_create_app_view.py


示例14: test_AppForm_should_be_in_context

    def test_AppForm_should_be_in_context(self, get):
        content = u"""[{"Name":"python"},{"Name":"ruby"},{"Name":"static"}]"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().get("/")
        request.session = {}

        view = CreateApp()
        view.plans = lambda r: ("basic", [("basic", "basic")])
        view.teams = lambda r: []
        view.pools = lambda r: []
        response = view.get(request)

        app_form = response.context_data['app_form']
        self.assertIsInstance(app_form, forms.AppForm)
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:16,代码来源:test_create_app_view.py


示例15: test_post_without_name_should_return_form_with_errors

    def test_post_without_name_should_return_form_with_errors(self, get):
        content = u"""[{"Name":"python"},{"Name":"ruby"},{"Name":"static"}]"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().post("/", {"name": ""})
        request.session = {}

        view = CreateApp()
        view.plans = lambda r: ("small", [("small", "small")])
        view.teams = lambda r: []
        view.pools = lambda r: []
        response = view.post(request)

        form = response.context_data.get('app_form')
        self.assertIn('name', form.errors)
        self.assertIn(u'This field is required.', form.errors.get('name'))
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:17,代码来源:test_create_app_view.py


示例16: test_post_should_send_to_tsuru_with_args_expected

    def test_post_should_send_to_tsuru_with_args_expected(self, post, get):
        post.return_value = Mock(status_code=200)

        data = {"name": "myepe", "platform": "django", "plan": "basic"}
        request = RequestFactory().post("/", data)
        request.session = {'tsuru_token': 'tokentest'}

        view = CreateApp()
        view.plans = lambda r: ("basic", [("basic", "basic")])
        view.platforms = lambda r: [("django", "django")]
        view.post(request)

        self.assertEqual(1, post.call_count)
        url = '{}/apps'.format(settings.TSURU_HOST)
        post.assert_called_with(
            url,
            data='{"platform": "django", "name": "myepe", "plan": {"name": "basic"}}',
            headers={'authorization': request.session['tsuru_token']}
        )
开发者ID:digideskio,项目名称:tsuru-dashboard,代码行数:19,代码来源:test_create_app_view.py


示例17: test_post_with_errors_should_show_error_message

    def test_post_with_errors_should_show_error_message(self, get, error):
        content = u"""[{"Name":"python"},{"Name":"ruby"},{"Name":"static"}]"""
        m = Mock(status_code=200, content=content)
        m.json.return_value = json.loads(content)
        get.return_value = m
        request = RequestFactory().post(
            "/",
            {"name": "myepe", "platform": "python"})
        request.session = {}

        view = CreateApp()
        view.plans = lambda r: ("small", [("small", "small")])
        view.teams = lambda r: []
        view.pools = lambda r: []

        view.post(request)

        error.assert_called_with(request, u'Error creating app', fail_silently=True)
开发者ID:tsuru,项目名称:tsuru-dashboard,代码行数:18,代码来源:test_create_app_view.py


示例18: test_pools_when_api_returns_no_content

 def test_pools_when_api_returns_no_content(self, get):
     mocked_response = Mock(status_code=204)
     get.return_value = mocked_response
     view = CreateApp()
     pools = view.pools(self.request)
     self.assertListEqual([('', '')], pools)
开发者ID:tsuru,项目名称:tsuru-dashboard,代码行数:6,代码来源:test_create_app_view.py



注:本文中的tsuru_dashboard.apps.views.CreateApp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logger.debug函数代码示例发布时间:2022-05-27
下一篇:
Python tst_scene_render.TestSceneRender类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap