Exemplo n.º 1
0
    def stream_index(self, bucket, index, startkey, endkey=None,
                     return_terms=None, max_results=None, continuation=None):
        """
        Queries a secondary index, streaming matching keys through an
        iterator.

        :param bucket: the bucket whose index will be queried
        :type bucket: RiakBucket
        :param index: the index to query
        :type index: string
        :param startkey: the sole key to query, or beginning of the query range
        :type startkey: string, integer
        :param endkey: the end of the query range (optional if equality)
        :type endkey: string, integer
        :param return_terms: whether to include the secondary index value
        :type return_terms: boolean
        :param max_results: the maximum number of results to return (page size)
        :type max_results: integer
        :param continuation: the opaque continuation returned from a
            previous paginated request
        :type continuation: string
        :rtype: :class:`riak.client.index_page.IndexPage`
        """
        page = IndexPage(self, bucket, index, startkey, endkey,
                         return_terms, max_results)
        with self._transport() as transport:
            page.stream = True
            page.results = transport.stream_index(
                bucket, index, startkey, endkey, return_terms=return_terms,
                max_results=max_results, continuation=continuation)
            return page
Exemplo n.º 2
0
    def stream_index(
        self,
        bucket,
        index,
        startkey,
        endkey=None,
        return_terms=None,
        max_results=None,
        continuation=None,
        timeout=None,
        term_regex=None,
    ):
        """
        Queries a secondary index, streaming matching keys through an
        iterator.

        :param bucket: the bucket whose index will be queried
        :type bucket: RiakBucket
        :param index: the index to query
        :type index: string
        :param startkey: the sole key to query, or beginning of the query range
        :type startkey: string, integer
        :param endkey: the end of the query range (optional if equality)
        :type endkey: string, integer
        :param return_terms: whether to include the secondary index value
        :type return_terms: boolean
        :param max_results: the maximum number of results to return (page size)
        :type max_results: integer
        :param continuation: the opaque continuation returned from a
            previous paginated request
        :type continuation: string
        :param timeout: a timeout value in milliseconds, or 'infinity'
        :type timeout: int
        :param term_regex: a regular expression used to filter index terms
        :type term_regex: string
        :rtype: :class:`riak.client.index_page.IndexPage`
        """
        if timeout != "infinity":
            _validate_timeout(timeout)

        with self._transport() as transport:
            page = IndexPage(self, bucket, index, startkey, endkey, return_terms, max_results, term_regex)
            page.stream = True
            page.results = transport.stream_index(
                bucket,
                index,
                startkey,
                endkey,
                return_terms=return_terms,
                max_results=max_results,
                continuation=continuation,
                timeout=timeout,
                term_regex=term_regex,
            )
            return page
Exemplo n.º 3
0
    def setUp(self):
		#设置无头浏览器
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        # 登录
        self.driver = webdriver.Chrome(executable_path=(r"C:\Users\yujing\AppData\Local\Programs\Python\Python37\chromedriver.exe"), chrome_options=chrome_options)
        self.driver.maximize_window()
        self.driver.get("http://120.79.176.157:8012/Index/login.html")
        self.bid_page = BidPage(self.driver)
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.person_page = PersonPage(self.driver)
        self.login_page.login("18684720553", "python")
Exemplo n.º 4
0
 def setUp(self):
     chrome_options = Options()
     chrome_options.add_argument("--headless")
     # 登录
     self.driver = webdriver.Chrome(
         executable_path=(PD.driver_path),
         chrome_options=chrome_options)
     self.driver.maximize_window()
     self.driver.get(PD.login_url)
     self.bid_page = BidPage(self.driver)
     self.login_page = LoginPage(self.driver)
     self.index_page = IndexPage(self.driver)
     self.person_page = PersonPage(self.driver)
     self.login_page.login(PD.username, PD.password)
Exemplo n.º 5
0
    def get_index(self,
                  transport,
                  bucket,
                  index,
                  startkey,
                  endkey=None,
                  return_terms=None,
                  max_results=None,
                  continuation=None):
        """
        get_index(bucket, index, startkey, endkey=None, return_terms=None,\
                  max_results=None, continuation=None)

        Queries a secondary index, returning matching keys.

        .. note:: This request is automatically retried :attr:`RETRY_COUNT`
           times if it fails due to network error.

        :param bucket: the bucket whose index will be queried
        :type bucket: RiakBucket
        :param index: the index to query
        :type index: string
        :param startkey: the sole key to query, or beginning of the query range
        :type startkey: string, integer
        :param endkey: the end of the query range (optional if equality)
        :type endkey: string, integer
        :param return_terms: whether to include the secondary index value
        :type return_terms: boolean
        :param max_results: the maximum number of results to return (page size)
        :type max_results: integer
        :param continuation: the opaque continuation returned from a
            previous paginated request
        :type continuation: string
        :rtype: :class:`riak.client.index_page.IndexPage`
        """
        page = IndexPage(self, bucket, index, startkey, endkey, return_terms,
                         max_results)

        results, continuation = transport.get_index(bucket,
                                                    index,
                                                    startkey,
                                                    endkey,
                                                    return_terms=return_terms,
                                                    max_results=max_results,
                                                    continuation=continuation)

        page.results = results
        page.continuation = continuation
        return page
Exemplo n.º 6
0
    def get_index(self, transport, bucket, index, startkey, endkey=None,
                  return_terms=None, max_results=None, continuation=None,
                  timeout=None, term_regex=None):
        """
        get_index(bucket, index, startkey, endkey=None, return_terms=None,\
                  max_results=None, continuation=None, timeout=None,\
                  term_regex=None)

        Queries a secondary index, returning matching keys.

        .. note:: This request is automatically retried :attr:`retries`
           times if it fails due to network error.

        :param bucket: the bucket whose index will be queried
        :type bucket: RiakBucket
        :param index: the index to query
        :type index: string
        :param startkey: the sole key to query, or beginning of the query range
        :type startkey: string, integer
        :param endkey: the end of the query range (optional if equality)
        :type endkey: string, integer
        :param return_terms: whether to include the secondary index value
        :type return_terms: boolean
        :param max_results: the maximum number of results to return (page size)
        :type max_results: integer
        :param continuation: the opaque continuation returned from a
            previous paginated request
        :type continuation: string
        :param timeout: a timeout value in milliseconds, or 'infinity'
        :type timeout: int
        :param term_regex: a regular expression used to filter index terms
        :type term_regex: string
        :rtype: :class:`~riak.client.index_page.IndexPage`
        """
        if timeout != 'infinity':
            _validate_timeout(timeout)

        page = IndexPage(self, bucket, index, startkey, endkey,
                         return_terms, max_results, term_regex)

        results, continuation = transport.get_index(
            bucket, index, startkey, endkey, return_terms=return_terms,
            max_results=max_results, continuation=continuation,
            timeout=timeout, term_regex=term_regex)

        page.results = results
        page.continuation = continuation
        return page
Exemplo n.º 7
0
 def test_login_success(self):
     # 步骤
     self.login_page.login(LD.success_data["username"],
                           LD.success_data["password"])
     # 验证-检查点
     # self.assertEqual(self.driver.current_url, "http://120.79.176.157:8012/Index/index")
     self.assertEqual(
         IndexPage(self.driver).get_nickName(),
         LD.success_data["check_nickname"])
Exemplo n.º 8
0
class TestInvest(unittest.TestCase):

    def setUp(self):
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        # 登录
        self.driver = webdriver.Chrome(
            executable_path=(PD.driver_path),
            chrome_options=chrome_options)
        self.driver.maximize_window()
        self.driver.get(PD.login_url)
        self.bid_page = BidPage(self.driver)
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.person_page = PersonPage(self.driver)
        self.login_page.login(PD.username, PD.password)

    def tearDown(self):
        self.driver.quit()

    def test_invest_success(self):
        # 进入个人详情页面,查看当前账户余额
        self.index_page.change_to_person_page()
        before_invest = self.person_page.get_balance()
        # 返回首页
        self.driver.back()
        time.sleep(5)
        # 首页选择一个标来进行投资
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(ID.input_money)
        self.bid_page.click_submit_button()
    #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.success_invest_msg(),ID.expect_success_invest_msg)
        # 投资成功,查看并激活
        self.bid_page.click_active_button()
    #     进入个人详情页面,读取投资后的个人账户余额
        # 刷新
        self.driver.refresh()
        time.sleep(2)
        after_invest = self.person_page.get_balance()
        self.assertEqual(int(float(before_invest)-float(after_invest)), ID.input_money)

    def test_invest_failed_by_No100(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(150)
        self.bid_page.click_submit_button()
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no100(), ID.expext_msg_by_no100)

    def test_invest_failed_by_No10(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(15)
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no10(), ID.expext_msg_by_no10)
Exemplo n.º 9
0
class TestInvest(unittest.TestCase):

    def setUp(self):
		#设置无头浏览器
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        # 登录
        self.driver = webdriver.Chrome(executable_path=(r"C:\Users\yujing\AppData\Local\Programs\Python\Python37\chromedriver.exe"), chrome_options=chrome_options)
        self.driver.maximize_window()
        self.driver.get("http://120.79.176.157:8012/Index/login.html")
        self.bid_page = BidPage(self.driver)
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.person_page = PersonPage(self.driver)
        self.login_page.login("18684720553", "python")

    def tearDown(self):
        self.driver.quit()

    def test_invest_success(self):

        # 进入个人详情页面,查看当前账户余额
        self.index_page.change_to_person_page()
        before_invest = self.person_page.get_balance()
        # 返回首页
        self.driver.back()
        time.sleep(5)
        # 首页选择一个标来进行投资
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(1000)
        self.bid_page.click_submit_button()
    #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.success_invest_msg(),"投标成功!")
        # 投资成功,查看并激活
        self.bid_page.click_active_button()
    #     进入个人详情页面,读取投资后的个人账户余额
        # 刷新
        self.driver.refresh()
        time.sleep(2)
        after_invest = self.person_page.get_balance()
        self.assertEqual(int(float(before_invest)-float(after_invest)), 1000)

    def test_invest_failed_by_No100(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(150)
        self.bid_page.click_submit_button()
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no100(), "投标金额必须为100的倍数")

    def test_invest_failed_by_No10(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(15)
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no10(), "请输入10的整数倍")
Exemplo n.º 10
0
    def stream_index(self,
                     bucket,
                     index,
                     startkey,
                     endkey=None,
                     return_terms=None,
                     max_results=None,
                     continuation=None):
        """
        Queries a secondary index, streaming matching keys through an
        iterator.

        :param bucket: the bucket whose index will be queried
        :type bucket: RiakBucket
        :param index: the index to query
        :type index: string
        :param startkey: the sole key to query, or beginning of the query range
        :type startkey: string, integer
        :param endkey: the end of the query range (optional if equality)
        :type endkey: string, integer
        :param return_terms: whether to include the secondary index value
        :type return_terms: boolean
        :param max_results: the maximum number of results to return (page size)
        :type max_results: integer
        :param continuation: the opaque continuation returned from a
            previous paginated request
        :type continuation: string
        :rtype: :class:`riak.client.index_page.IndexPage`
        """
        page = IndexPage(self, bucket, index, startkey, endkey, return_terms,
                         max_results)
        with self._transport() as transport:
            page.stream = True
            page.results = transport.stream_index(bucket,
                                                  index,
                                                  startkey,
                                                  endkey,
                                                  return_terms=return_terms,
                                                  max_results=max_results,
                                                  continuation=continuation)
            return page
Exemplo n.º 11
0
    def get_index(self, transport, bucket, index, startkey, endkey=None,
                  return_terms=None, max_results=None, continuation=None):
        """
        get_index(bucket, index, startkey, endkey=None, return_terms=None,\
                  max_results=None, continuation=None)

        Queries a secondary index, returning matching keys.

        .. note:: This request is automatically retried :attr:`RETRY_COUNT`
           times if it fails due to network error.

        :param bucket: the bucket whose index will be queried
        :type bucket: RiakBucket
        :param index: the index to query
        :type index: string
        :param startkey: the sole key to query, or beginning of the query range
        :type startkey: string, integer
        :param endkey: the end of the query range (optional if equality)
        :type endkey: string, integer
        :param return_terms: whether to include the secondary index value
        :type return_terms: boolean
        :param max_results: the maximum number of results to return (page size)
        :type max_results: integer
        :param continuation: the opaque continuation returned from a
            previous paginated request
        :type continuation: string
        :rtype: :class:`riak.client.index_page.IndexPage`
        """
        page = IndexPage(self, bucket, index, startkey, endkey,
                         return_terms, max_results)

        results, continuation = transport.get_index(
            bucket, index, startkey, endkey, return_terms=return_terms,
            max_results=max_results, continuation=continuation)

        page.results = results
        page.continuation = continuation
        return page
Exemplo n.º 12
0
    def stream_index(self, bucket, index, startkey, endkey=None,
                     return_terms=None, max_results=None, continuation=None,
                     timeout=None, term_regex=None):
        """
        Queries a secondary index, streaming matching keys through an
        iterator.

        The caller should explicitly close the returned iterator,
        either using :func:`contextlib.closing` or calling ``close()``
        explicitly. Consuming the entire iterator will also close the
        stream. If it does not, the associated connection might not be
        returned to the pool. Example::

            from contextlib import closing

            # Using contextlib.closing
            with closing(client.stream_index(mybucket, 'name_bin',
                                             'Smith')) as index:
                for key in index:
                    do_something(key)

            # Explicit close()
            stream = client.stream_index(mybucket, 'name_bin', 'Smith')
            for key in stream:
                 do_something(key)
            stream.close()

        :param bucket: the bucket whose index will be queried
        :type bucket: RiakBucket
        :param index: the index to query
        :type index: string
        :param startkey: the sole key to query, or beginning of the query range
        :type startkey: string, integer
        :param endkey: the end of the query range (optional if equality)
        :type endkey: string, integer
        :param return_terms: whether to include the secondary index value
        :type return_terms: boolean
        :param max_results: the maximum number of results to return (page size)
        :type max_results: integer
        :param continuation: the opaque continuation returned from a
            previous paginated request
        :type continuation: string
        :param timeout: a timeout value in milliseconds, or 'infinity'
        :type timeout: int
        :param term_regex: a regular expression used to filter index terms
        :type term_regex: string
        :rtype: :class:`~riak.client.index_page.IndexPage`

        """
        if timeout != 'infinity':
            _validate_timeout(timeout)

        page = IndexPage(self, bucket, index, startkey, endkey,
                         return_terms, max_results, term_regex)
        page.stream = True
        resource = self._acquire()
        transport = resource.object
        page.results = transport.stream_index(
            bucket, index, startkey, endkey, return_terms=return_terms,
            max_results=max_results, continuation=continuation,
            timeout=timeout, term_regex=term_regex)
        page.results.attach(resource)
        return page
Exemplo n.º 13
0
 def test_login_success(self):
     # 步骤
     self.login_page.login("18684720553", "python")
     # 验证-检查点
     # self.assertEqual(self.driver.current_url, "http://120.79.176.157:8012/Index/index")
     self.assertEqual(IndexPage(self.driver).get_nickName(), "我的帐户[小蜜蜂96027]")