Skip to content
Snippets Groups Projects
Select Git revision
  • 4deb9b10a853e53d7aedf01c872db661f91fae47
  • main default
  • y3
  • y1
4 results

test_mc_openapi.py

Blame
  • test_mc_openapi.py 1.72 KiB
    from mc_openapi import __version__
    from mc_openapi.doml_mc.common_reqs import CommonRequirements
    import requests
    
    
    def test_version():
        assert __version__ == '1.1.0'
    
    
    def test_post_nginx_sat():
        with open("tests/doml/nginx-openstack_v2.0.domlx", "r") as f:
            doml = f.read()
    
        r = requests.post("http://0.0.0.0:8080/modelcheck", data=doml)
        payload = r.json()
        assert r.status_code == requests.codes.ok
        assert payload["result"] is not None
        assert payload["result"] == "sat"
    
    
    def test_post_faas_sat():
        with open("tests/doml/faas.domlx", "r") as f:
            doml = f.read()
    
        r = requests.post("http://0.0.0.0:8080/modelcheck", data=doml)
        payload = r.json()
        assert r.status_code == requests.codes.ok
        assert payload["result"] is not None
        assert payload["result"] == "unsat"
    
    
    def test_post_common_reqs():
        check_strings = [
            "is connected to no network interface.",
            "but they are deployed to nodes that cannot communicate through a common network.",
            "share the same IP address.",
            "is not deployed to any abstract infrastructure node.",
            "has not been mapped to any element in the active concretization.",
            "is mapped to no abstract infrastructure element."
        ]
    
        for req, err_desc in zip(CommonRequirements.get_all_requirements(), check_strings):
            with open(f"tests/doml/nginx-openstack_v2.0_wrong_{req.assert_name}.domlx", "r") as f:
                doml = f.read()
    
            r = requests.post("http://0.0.0.0:8080/modelcheck", data=doml)
            payload = r.json()
            assert r.status_code == requests.codes.ok
            assert payload["result"] is not None
            assert payload["result"] == "unsat"
            assert err_desc in payload["description"]