Ejemplo n.º 1
0
 def test_when_request_has_no_method(self):
     request = RequestNode({}, endpoint=EndpointNode({}))
     assert request.http_method == "GET"
Ejemplo n.º 2
0
 def test_when_node_has_delay(self):
     node = EndpointNode({"name": "node", "delay": 1})
     assert node.delay == 1
Ejemplo n.º 3
0
 def test_when_parent_has_name(self):
     parent = EndpointNode({"name": "root"})
     node = EndpointNode({"name": "child-node"}, parent=parent)
     assert node.name == "root::child-node"
Ejemplo n.º 4
0
    def test_init_spec_and_endpoint(self):
        endpoint = EndpointNode({"name": "foo", "requests": [{}]})
        request = RequestNode(spec={"name": "bar"}, endpoint=endpoint)

        assert request.endpoint == endpoint
        assert request.spec == {"name": "bar"}
Ejemplo n.º 5
0
 def test_when_request_has_name(self):
     request = RequestNode(
         {"name": "list-users", "path": "http:foo.com"},
         endpoint=EndpointNode({"name": "foo", "requests": []}),
     )
     assert request.name == "list-users"
Ejemplo n.º 6
0
 def test_when_request_has_no_method(self):
     request = RequestNode(
         {"name": "foo", "path": "http:foo.com"},
         endpoint=EndpointNode({"name": "foo", "requests": [{}]}),
     )
     assert request.http_method == "GET"
Ejemplo n.º 7
0
 def test_when_parent_has_name(self):
     parent = EndpointNode({"name": "root"})
     node = EndpointNode({"name": "child-node"}, parent=parent)
     assert repr(node) == "<EndpointNode root::child-node>"
Ejemplo n.º 8
0
 def test_with_trailing_slashes(self):
     endpoint = EndpointNode({"path": "http://foo.com/"})
     request = RequestNode({"path": "/foo/"}, endpoint=endpoint)
     assert request.full_url_path == "http://foo.com/foo/"
Ejemplo n.º 9
0
 def test_when_endpoint_has_no_headers(self):
     headers = {"abc": "def"}
     request = RequestNode({"headers": headers},
                           endpoint=EndpointNode({}))
     assert request.headers == headers
Ejemplo n.º 10
0
 def test_when_endpoint_has_no_url(self):
     path = "http://foo.com"
     request = RequestNode({"path": path}, endpoint=EndpointNode({}))
     assert request.full_url_path == path
Ejemplo n.º 11
0
 def test_when_endpoint_has_url(self):
     endpoint_path = "http://foo.com/api"
     endpoint = EndpointNode({"path": endpoint_path})
     request = RequestNode({"path": "/foo"}, endpoint=endpoint)
     assert request.full_url_path == f"http://foo.com/api/foo"
Ejemplo n.º 12
0
 def test_request_with_no_path(self):
     base_path = "http://foo.com/"
     request = RequestNode({},
                           endpoint=EndpointNode({"path": base_path}))
     assert request.full_url_path == base_path
Ejemplo n.º 13
0
 def test_when_request_has_no_name(self):
     request = RequestNode({}, endpoint=EndpointNode({}))
Ejemplo n.º 14
0
 def test_when_request_has_name(self):
     request = RequestNode({"name": "list-users"},
                           endpoint=EndpointNode({}))
     assert request.name == "list-users"
Ejemplo n.º 15
0
 def test_when_both_request_and_endpoint_have_delay(self):
     request = RequestNode(
         {"name": "foo", "delay": 3},
         endpoint=EndpointNode({"name": "bar", "delay": 4}),
     )
     assert request.delay == 3
Ejemplo n.º 16
0
 def spec_evaluator(self):
     endpoint = EndpointNode({})
     return SpecEvaluator(endpoint)
Ejemplo n.º 17
0
 def test_when_request_has_no_body(self):
     request = RequestNode(
         {"path": "http://foo.com", "name": "foo"},
         endpoint=EndpointNode({"name": "foo", "requests": [{}]}),
     )
     assert request.body is None
Ejemplo n.º 18
0
        def test_missing_required_keys(self):
            with pytest.raises(MissingMandatoryKeyError) as excinfo:
                endpoints = [{}, {}]
                EndpointNode({"endpoints": endpoints})

            assert str(excinfo.value) == "Missing 'name' key(s) at 'endpoint' scope"
Ejemplo n.º 19
0
 def test_when_parent_has_no_name(self):
     node = EndpointNode({"name": "child-node"}, parent=EndpointNode({}))
     assert repr(node) == "<EndpointNode child-node>"
Ejemplo n.º 20
0
 def test_when_request_has_body(self):
     request = RequestNode(
         {"body": {"abc": "def"}, "path": "http://foo.com", "name": "foo",},
         endpoint=EndpointNode({"name": "foo", "requests": [{}]}),
     )
     assert request.body == {"abc": "def"}
Ejemplo n.º 21
0
 def test_when_request_has_no_delay(self):
     request = RequestNode({"name": "foo"},
                           endpoint=EndpointNode({"name": "bar"}))
     assert request.delay == 0
Ejemplo n.º 22
0
 def test_with_trailintest_with_path_not_stringg_slashes(self):
     endpoint = EndpointNode(
         {"name": "foo", "requests": [{}], "path": "http://foo.com/"}
     )
     request = RequestNode({"name": "foo", "path": []}, endpoint=endpoint)
     assert request.full_url_path == "http://foo.com/[]"
Ejemplo n.º 23
0
 def spec_evaluator(self):
     parent = EndpointNode({"name": "bar", "requests": [{}]})
     endpoint = EndpointNode({"name": "foo", "requests": [{}]}, parent)
     return SpecEvaluator(endpoint, {"name": "foo"})
Ejemplo n.º 24
0
 def spec_evaluator(self):
     endpoint = EndpointNode({"name": "foo", "requests": [{}]})
     return SpecEvaluator(endpoint)
Ejemplo n.º 25
0
 def test_when_path_is_not_defined(self):
     endpoint = EndpointNode({"name": "foo", "requests": [{}]})
     request = RequestNode(spec={"name": "bar"}, endpoint=endpoint)
     assert repr(request) == "<RequestNode >"
Ejemplo n.º 26
0
 def test_when_parent_has_no_name(self):
     base_path = "http://foo.com"
     node = EndpointNode({"name": "child-node"},
                         parent=EndpointNode({}))
     assert node.name == "child-node"
Ejemplo n.º 27
0
 def test_when_parent_has_no_name(self):
     node = EndpointNode({"name": "child-node"},
                         parent=EndpointNode({}))
     assert node.name == "child-node"
Ejemplo n.º 28
0
 def test_when_endpoint_has_delay(self):
     request = RequestNode(
         {"name": "foo"},
         endpoint=EndpointNode({"name": "bar", "delay": 2}),
     )
     assert request.delay == 2
Ejemplo n.º 29
0
 def test_no_required_keys_for_root(self):
     assert EndpointNode({})
Ejemplo n.º 30
0
 def test_when_request_has_method(self):
     request = RequestNode({"method": "put"}, endpoint=EndpointNode({}))
     assert request.http_method == "PUT"