当前位置: 首页>>代码示例>>Python>>正文


Python RestSetup.get_test_vars方法代码示例

本文整理汇总了Python中test.ably.restsetup.RestSetup.get_test_vars方法的典型用法代码示例。如果您正苦于以下问题:Python RestSetup.get_test_vars方法的具体用法?Python RestSetup.get_test_vars怎么用?Python RestSetup.get_test_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.ably.restsetup.RestSetup的用法示例。


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

示例1: test_request_token_with_specified_key

# 需要导入模块: from test.ably.restsetup import RestSetup [as 别名]
# 或者: from test.ably.restsetup.RestSetup import get_test_vars [as 别名]
 def test_request_token_with_specified_key(self):
     key = RestSetup.get_test_vars()["keys"][1]
     token_details = self.ably.auth.request_token(
         key_name=key["key_name"], key_secret=key["key_secret"])
     self.assertIsNotNone(token_details.token, msg="Expected token")
     self.assertEqual(key.get("capability"),
                      token_details.capability,
                      msg="Unexpected capability")
开发者ID:vintasoftware,项目名称:ably-python,代码行数:10,代码来源:resttoken_test.py

示例2: setUpClass

# 需要导入模块: from test.ably.restsetup import RestSetup [as 别名]
# 或者: from test.ably.restsetup.RestSetup import get_test_vars [as 别名]
    def setUpClass(cls):
        RestSetup._RestSetup__test_vars = None
        test_vars = RestSetup.get_test_vars()
        cls.ably = AblyRest(key=test_vars["keys"][0]["key_str"],
                            rest_host=test_vars["host"],
                            port=test_vars["port"],
                            tls_port=test_vars["tls_port"],
                            tls=test_vars["tls"])
        cls.ably_text = AblyRest(key=test_vars["keys"][0]["key_str"],
                                 rest_host=test_vars["host"],
                                 port=test_vars["port"],
                                 tls_port=test_vars["tls_port"],
                                 tls=test_vars["tls"],
                                 use_binary_protocol=False)

        cls.last_year = datetime.now().year - 1
        cls.previous_year = datetime.now().year - 2
        cls.last_interval = datetime(cls.last_year, 2, 3, 15, 5)
        cls.previous_interval = datetime(cls.previous_year, 2, 3, 15, 5)
        previous_year_stats = 120
        stats = [
            {
                'intervalId': Stats.to_interval_id(cls.last_interval -
                                                   timedelta(minutes=2),
                                                   'minute'),
                'inbound': {'realtime': {'messages': {'count': 50, 'data': 5000}}},
                'outbound': {'realtime': {'messages': {'count': 20, 'data': 2000}}}
            },
            {
                'intervalId': Stats.to_interval_id(cls.last_interval - timedelta(minutes=1),
                                                   'minute'),
                'inbound': {'realtime': {'messages': {'count': 60, 'data': 6000}}},
                'outbound': {'realtime': {'messages': {'count': 10, 'data': 1000}}}
            },
            {
                'intervalId': Stats.to_interval_id(cls.last_interval, 'minute'),
                'inbound': {'realtime': {'messages': {'count': 70, 'data': 7000}}},
                'outbound': {'realtime': {'messages': {'count': 40, 'data': 4000}}},
                'persisted': {'presence': {'count': 20, 'data': 2000}},
                'connections': {'tls':   {'peak': 20, 'opened': 10}},
                'channels': {'peak': 50, 'opened': 30},
                'apiRequests': {'succeeded': 50, 'failed': 10},
                'tokenRequests': {'succeeded': 60, 'failed': 20},
            }
        ]

        previous_stats = []
        for i in range(previous_year_stats):
            previous_stats.append(
                {
                    'intervalId': Stats.to_interval_id(cls.previous_interval -
                                                       timedelta(minutes=i),
                                                       'minute'),
                    'inbound':  {'realtime': {'messages': {'count': i}}}
                }
            )

        cls.ably.http.post('/stats', native_data=stats + previous_stats)
开发者ID:vintasoftware,项目名称:ably-python,代码行数:60,代码来源:restappstats_test.py

示例3: import

# 需要导入模块: from test.ably.restsetup import RestSetup [as 别名]
# 或者: from test.ably.restsetup.RestSetup import get_test_vars [as 别名]
import six
import msgpack
import responses

from ably import AblyRest
from ably.http.paginatedresult import PaginatedResult
from ably.types.presence import (PresenceMessage,
                                 make_encrypted_presence_response_handler)
from ably import ChannelOptions
from ably.util.crypto import get_default_params

from test.ably.utils import dont_vary_protocol, VaryByProtocolTestsMetaclass, BaseTestCase
from test.ably.restsetup import RestSetup

test_vars = RestSetup.get_test_vars()


@six.add_metaclass(VaryByProtocolTestsMetaclass)
class TestPresence(BaseTestCase):

    def setUp(self):
        self.ably = AblyRest(test_vars["keys"][0]["key_str"],
                             rest_host=test_vars["host"],
                             port=test_vars["port"],
                             tls_port=test_vars["tls_port"],
                             tls=test_vars["tls"])
        self.per_protocol_setup(True)

    def per_protocol_setup(self, use_binary_protocol):
        # This will be called every test that vary by protocol for each protocol
开发者ID:vintasoftware,项目名称:ably-python,代码行数:32,代码来源:restpresence_test.py

示例4: setup

# 需要导入模块: from test.ably.restsetup import RestSetup [as 别名]
# 或者: from test.ably.restsetup.RestSetup import get_test_vars [as 别名]
def setup():
    RestSetup.get_test_vars()
    yield
    RestSetup.clear_test_vars()
开发者ID:ably,项目名称:ably-python,代码行数:6,代码来源:conftest.py

示例5: setup_package

# 需要导入模块: from test.ably.restsetup import RestSetup [as 别名]
# 或者: from test.ably.restsetup.RestSetup import get_test_vars [as 别名]
def setup_package():
    RestSetup.get_test_vars()
开发者ID:avsd,项目名称:ably-python,代码行数:4,代码来源:__init__.py

示例6: test_request_token_with_specified_key

# 需要导入模块: from test.ably.restsetup import RestSetup [as 别名]
# 或者: from test.ably.restsetup.RestSetup import get_test_vars [as 别名]
 def test_request_token_with_specified_key(self):
     key = RestSetup.get_test_vars()["keys"][1]
     token_details = self.ably.auth.request_token(
         key_name=key["key_name"], key_secret=key["key_secret"])
     assert token_details.token is not None, "Expected token"
     assert key.get("capability") == token_details.capability, "Unexpected capability"
开发者ID:ably,项目名称:ably-python,代码行数:8,代码来源:resttoken_test.py


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