Exemplo n.º 1
0
    def test_jsonld(self):
        prueba = {"id": "test", "activities": [], "entries": []}
        r = Results(**prueba)
        print("Response's context: ")
        pprint(r._context)

        assert r.id == "test"

        j = r.jsonld(with_context=True)
        print("As JSON:")
        pprint(j)
        assert ("@context" in j)
        assert ("marl" in j["@context"])
        assert ("entries" in j["@context"])
        assert (j["@id"] == "test")
        assert "id" not in j

        r6 = Results(**prueba)
        e = Entry({"@id": "ohno", "nif:isString": "Just testing"})
        r6.entries.append(e)
        logging.debug("Reponse 6: %s", r6)
        assert ("marl" in r6._context)
        assert ("entries" in r6._context)
        j6 = r6.jsonld(with_context=True)
        logging.debug("jsonld: %s", j6)
        assert ("@context" in j6)
        assert ("entries" in j6)
        assert ("activities" in j6)
        resp = r6.flask()
        received = json.loads(resp.data.decode())
        logging.debug("Response: %s", j6)
        assert (received["entries"])
        assert (received["entries"][0]["nif:isString"] == "Just testing")
        assert (received["entries"][0]["nif:isString"] != "Not testing")
Exemplo n.º 2
0
    def test_jsonld(self):
        prueba = {"id": "test", "analysis": [], "entries": []}
        r = Results(**prueba)
        print("Response's context: ")
        pprint(r._context)

        assert r.id == "test"

        j = r.jsonld(with_context=True)
        print("As JSON:")
        pprint(j)
        assert ("@context" in j)
        assert ("marl" in j["@context"])
        assert ("entries" in j["@context"])
        assert (j["@id"] == "test")
        assert "id" not in j

        r6 = Results(**prueba)
        e = Entry({"@id": "ohno", "nif:isString": "Just testing"})
        r6.entries.append(e)
        logging.debug("Reponse 6: %s", r6)
        assert ("marl" in r6._context)
        assert ("entries" in r6._context)
        j6 = r6.jsonld(with_context=True)
        logging.debug("jsonld: %s", j6)
        assert ("@context" in j6)
        assert ("entries" in j6)
        assert ("analysis" in j6)
        resp = r6.flask()
        received = json.loads(resp.data.decode())
        logging.debug("Response: %s", j6)
        assert (received["entries"])
        assert (received["entries"][0]["nif:isString"] == "Just testing")
        assert (received["entries"][0]["nif:isString"] != "Not testing")
Exemplo n.º 3
0
 def test_patch_json(self):
     r = Results()
     with patch_requests(r):
         res = requests.get('http://example.com')
         assert res.content == json.dumps(r.jsonld())
         js = res.json()
         assert js
         assert js['@type'] == r['@type']
Exemplo n.º 4
0
 def test_patch_json(self):
     r = Results()
     with patch_requests(ENDPOINT, r):
         res = requests.get(ENDPOINT)
         assert res.text == json.dumps(r.jsonld())
         js = res.json()
         assert js
         assert js['@type'] == r['@type']
Exemplo n.º 5
0
 def test_patch_json(self):
     r = Results()
     with patch_requests(ENDPOINT, r):
         res = requests.get(ENDPOINT)
         assert res.text == json.dumps(r.jsonld())
         js = res.json()
         assert js
         assert js['@type'] == r['@type']
Exemplo n.º 6
0
    def test_jsonld(self):
        ctx = os.path.normpath(os.path.join(__file__, "..", "..", "..", "senpy", "schemas", "context.jsonld"))
        prueba = {"id": "test",
                  "analysis": [],
                  "entries": []}
        r = Results(**prueba)
        print("Response's context: ")
        pprint(r.context)

        assert r.id == "test"

        j = r.jsonld(with_context=True)
        print("As JSON:")
        pprint(j)
        assert("@context" in j)
        assert("marl" in j["@context"])
        assert("entries" in j["@context"])
        assert(j["@id"] == "test")
        assert "id" not in j

        r6 = Results(**prueba)
        r6.entries.append(Entry({"@id":"ohno", "nif:isString":"Just testing"}))
        logging.debug("Reponse 6: %s", r6)
        assert("marl" in r6.context)
        assert("entries" in r6.context)
        j6 = r6.jsonld(with_context=True)
        logging.debug("jsonld: %s", j6)
        assert("@context" in j6)
        assert("entries" in j6)
        assert("analysis" in j6)
        resp = r6.flask()
        received = json.loads(resp.data.decode())
        logging.debug("Response: %s", j6)
        assert(received["entries"])
        assert(received["entries"][0]["nif:isString"] == "Just testing")
        assert(received["entries"][0]["nif:isString"] != "Not testing")