Example #1
0
    def test_multiple(self):
        r = list(language.parse_pathoc("GET:/ PUT:/"))
        assert r[0].method.string() == "GET"
        assert r[1].method.string() == "PUT"
        assert len(r) == 2

        l = """
            GET
            "/foo"
            ir,@1

            PUT

            "/foo



            bar"

            ir,@1
        """
        r = list(language.parse_pathoc(l))
        assert len(r) == 2
        assert r[0].method.string() == "GET"
        assert r[1].method.string() == "PUT"

        l = """
            get:"http://localhost:9999/p/200":ir,@1
            get:"http://localhost:9999/p/200":ir,@2
        """
        r = list(language.parse_pathoc(l))
        assert len(r) == 2
        assert r[0].method.string() == "GET"
        assert r[1].method.string() == "GET"
Example #2
0
    def test_multiple(self):
        r = list(language.parse_pathoc("GET:/ PUT:/"))
        assert r[0].method.string() == "GET"
        assert r[1].method.string() == "PUT"
        assert len(r) == 2

        l = """
            GET
            "/foo"

            PUT

            "/foo



            bar"
        """
        r = list(language.parse_pathoc(l, True))
        assert len(r) == 2
        assert r[0].method.string() == "GET"
        assert r[1].method.string() == "PUT"

        l = """
            get:"http://localhost:9999/p/200"
            get:"http://localhost:9999/p/200"
        """
        r = list(language.parse_pathoc(l, True))
        assert len(r) == 2
        assert r[0].method.string() == "GET"
        assert r[1].method.string() == "GET"
Example #3
0
 def tval(self,
          requests,
          showreq=False,
          showresp=False,
          explain=False,
          showssl=False,
          hexdump=False,
          timeout=None,
          ignorecodes=(),
          ignoretimeout=None,
          showsummary=True):
     s = cStringIO.StringIO()
     c = pathoc.Pathoc(("127.0.0.1", self.d.port),
                       ssl=self.ssl,
                       showreq=showreq,
                       showresp=showresp,
                       explain=explain,
                       hexdump=hexdump,
                       ignorecodes=ignorecodes,
                       ignoretimeout=ignoretimeout,
                       showsummary=showsummary,
                       fp=s)
     c.connect(showssl=showssl, fp=s)
     if timeout:
         c.settimeout(timeout)
     for i in requests:
         r = language.parse_pathoc(i).next()
         if explain:
             r = r.freeze(language.Settings())
         try:
             c.request(r)
         except NetlibException:
             pass
     return s.getvalue()
Example #4
0
 def test_nested_response(self):
     l = "get:/p:s'200'"
     r = list(language.parse_pathoc(l))
     assert len(r) == 1
     assert len(r[0].tokens) == 3
     assert isinstance(r[0].tokens[2], http.NestedResponse)
     assert r[0].values({})
 def test_nested_response(self):
     l = "get:/p:s'200'"
     r = list(language.parse_pathoc(l))
     assert len(r) == 1
     assert len(r[0].tokens) == 3
     assert isinstance(r[0].tokens[2], http.NestedResponse)
     assert r[0].values({})
Example #6
0
 def tval(
     self,
     requests,
     showreq=False,
     showresp=False,
     explain=False,
     showssl=False,
     hexdump=False,
     timeout=None,
     ignorecodes=(),
     ignoretimeout=None,
     showsummary=True
 ):
     s = cStringIO.StringIO()
     c = pathoc.Pathoc(
         ("127.0.0.1", self.d.port),
         ssl=self.ssl,
         showreq=showreq,
         showresp=showresp,
         explain=explain,
         hexdump=hexdump,
         ignorecodes=ignorecodes,
         ignoretimeout=ignoretimeout,
         showsummary=showsummary,
         fp=s
     )
     c.connect(showssl=showssl, fp=s)
     if timeout:
         c.settimeout(timeout)
     for i in requests:
         r = language.parse_pathoc(i).next()
         if explain:
             r = r.freeze(language.Settings())
         try:
             c.request(r)
         except (http.HttpError, tcp.NetLibError):
             pass
     return s.getvalue()
Example #7
0
def parse_request(s):
    return language.parse_pathoc(s).next()
Example #8
0
def test_times():
    reqs = list(language.parse_pathoc("get:/:x5"))
    assert len(reqs) == 5
    assert not reqs[0].times
def parse_request(s):
    return language.parse_pathoc(s).next()
Example #10
0
def test_times():
    reqs = list(language.parse_pathoc("get:/:x5"))
    assert len(reqs) == 5
    assert not reqs[0].times