Exemple #1
0
def service_JSON_accept_content_type_test():
    '''Test of JSON accept and content type headers for service invocation.'''
    i = '''{
  "http://tw.rpi.edu/instances/JamesMcCusker": {
    "http://xmlns.com/foaf/0.1/name": [
      {
        "type": "literal", 
        "value": "Jim McCusker"
      }
    ], 
    "http://www.w3.org/1999/02/22-rdf-syntax-ns#type": [
      {
        "type": "uri", 
        "value": "http://sadiframework.org/examples/hello.owl#NamedIndividual"
      }
    ]
  }
}'''
    c = sadi.setup_test_client(resource)
    resp = c.post('/',data=i,
                  headers={'Content-Type':'application/json','Accept':'application/json'})
    assert resp.status_code == 200
    g = Graph()
    print(resp.data)
    s = JSONSerializer()
    s.deserialize(g,resp.data,"application/json")
    assert len(g) > 0
Exemple #2
0
def service_JSON_accept_content_type_test():
    '''Test of JSON accept and content type headers for service invocation.'''
    i = '''{
  "http://tw.rpi.edu/instances/JamesMcCusker": {
    "http://xmlns.com/foaf/0.1/name": [
      {
        "type": "literal", 
        "value": "Jim McCusker"
      }
    ], 
    "http://www.w3.org/1999/02/22-rdf-syntax-ns#type": [
      {
        "type": "uri", 
        "value": "http://sadiframework.org/examples/hello.owl#NamedIndividual"
      }
    ]
  }
}'''
    c = sadi.setup_test_client(resource)
    resp = c.post('/',
                  data=i,
                  headers={
                      'Content-Type': 'application/json',
                      'Accept': 'application/json'
                  })
    assert resp.status_code == 200
    g = Graph()
    print resp.data
    s = JSONSerializer()
    s.deserialize(g, resp.data, "application/json")
    assert len(g) > 0
Exemple #3
0
def json_descriptor_test():
    '''Basic test of getting a service description in JSON from a SADI service.'''
    c = sadi.setup_test_client(resource)
    resp = c.get('/',headers={'Accept':'application/json'})
    assert resp.status_code == 200
    g = Graph()
    print(resp.data)
    s = JSONSerializer()
    s.deserialize(g,resp.data,"application/json")
    assert len(g) > 0
Exemple #4
0
def json_descriptor_test():
    '''Basic test of getting a service description in JSON from a SADI service.'''
    c = sadi.setup_test_client(resource)
    resp = c.get('/', headers={'Accept': 'application/json'})
    assert resp.status_code == 200
    g = Graph()
    print resp.data
    s = JSONSerializer()
    s.deserialize(g, resp.data, "application/json")
    assert len(g) > 0