Exemplo n.º 1
0
def update(entity):
    if 'id' in entity:
        del entity['id']
    client = datastore.Client()
    client.put(entity)
    entity['id'] = entity.key.id
    return entity
Exemplo n.º 2
0
    def test_update_bag_must_be_owner(self):
        with open(filepath('test-bag.json')) as f:
            bag_json = f.read()
        with open(filepath('test-bag-updated.json')) as f:
            updated_bag_json = f.read()
        with self.client as client:
            id = UUID('6f2c64e2-c65f-4e2d-b028-f89dfb71ce69')
            res = client.put(
                '/bags/%s' % id,
                data=bag_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            bag_url_v0 = urlparse(res.headers['Location'])
            self.assertEqual('/bags/%s' % id, bag_url_v0.path)
            self.assertEqual('version=0', bag_url_v0.query)

            res = client.put(
                '/bags/%s' % id,
                data=updated_bag_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
            self.assertEqual(res.status_code, http.client.FORBIDDEN)
Exemplo n.º 3
0
    def test_update_graph(self):
        with open(filepath('test-graph.json')) as f:
            graph_json = f.read()
        with open(filepath('test-graph-updated.json')) as f:
            updated_graph_json = f.read()
        with self.client as client:
            id = 'places/us-states'
            res = client.put(
                '/graphs/%s' % id,
                data=graph_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            graph_url_v0 = urlparse(res.headers['Location'])
            self.assertEqual('/graphs/%s' % id, graph_url_v0.path)
            self.assertEqual('version=0', graph_url_v0.query)

            res = client.put(
                '/graphs/%s' % id,
                data=updated_graph_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            graph_url_v1 = urlparse(res.headers['Location'])
            self.assertEqual('/graphs/%s' % id, graph_url_v1.path)
            self.assertEqual('version=1', graph_url_v1.query)

            res = client.get('/graphs/%s' % id)
            self.assertEqual(
                json.loads(res.get_data(as_text=True))[
                    'features'][0]['names'][0]['toponym'],
                'Minnesooooooota')
            self.assertEqual(
                res.headers['Content-Disposition'],
                'attachment; filename="periodo-graph-places-us-states.json"')

            res = client.get('/graphs/%s?version=0' % id)
            self.assertEqual(
                json.loads(res.get_data(as_text=True))[
                    'features'][0]['names'][0]['toponym'],
                'Minnesota')
            self.assertEqual(
                res.headers['Content-Disposition'],
                'attachment; '
                + 'filename="periodo-graph-places-us-states-v0.json"')

            res = client.get('/graphs/%s?version=1' % id)
            self.assertEqual(
                json.loads(res.get_data(as_text=True))[
                    'features'][0]['names'][0]['toponym'],
                'Minnesooooooota')
            self.assertEqual(
                res.headers['Content-Disposition'],
                'attachment; '
                + 'filename="periodo-graph-places-us-states-v1.json"')
Exemplo n.º 4
0
def insert(name, pw):
    client = datastore.Client()
    key = client.key("Account")
    entity = datastore.Entity(key=key)
    entity["name"] = name
    entity["pw"] = pw
    entity["created"] = datetime.now()
    client.put(entity)
    entity['id'] = entity.key.id
    return entity
Exemplo n.º 5
0
def insert(author, message):
    client = datastore.Client()
    key = client.key("Greeting")
    entity = datastore.Entity(key=key)
    entity["author"] = author
    entity["message"] = message
    entity["created"] = datetime.now()
    client.put(entity)
    entity['id'] = entity.key.id
    return entity
Exemplo n.º 6
0
def insert_comment(parent_id, message):
    client = datastore.Client()
    parent_key = client.key('Greeting', int(parent_id))
    key = client.key('Comment', parent=parent_key)
    entity = datastore.Entity(key=key)
    entity['message'] = message
    entity["created"] = datetime.now()
    client.put(entity)
    entity['id'] = entity.key.id
    return entity
Exemplo n.º 7
0
def insert(things, check):
    client = datastore.Client()
    key = client.key("TodoList")
    entity = datastore.Entity(key=key)
    entity["things"] = things
    entity["check"] = check
    entity["created"] = datetime.now()
    client.put(entity)
    entity['id'] = entity.key.id
    return entity
Exemplo n.º 8
0
def insert(target, users):
    client = datastore.Client()
    key = client.key("ScrapingDataSummary")
    entity = datastore.Entity(key=key)
    entity["target"] = target
    entity["over_num"] = users
    entity["created"] = datetime.now()
    client.put(entity)
    entity['id'] = entity.key.id
    # 追加した親データのkey_idを返す
    return entity.key.id
Exemplo n.º 9
0
    def test_update_bag_using_jsonld(self):
        with open(filepath('test-bag.json')) as f:
            bag_json = f.read()
        with open(filepath('test-bag.jsonld')) as f:
            bag_jsonld = f.read()
        with open(filepath('test-bag-updated.jsonld')) as f:
            updated_bag_jsonld = f.read()
        with self.client as client:
            id = UUID('6f2c64e2-c65f-4e2d-b028-f89dfb71ce69')
            res = client.put(
                '/bags/%s' % id,
                data=bag_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            bag_url_v0 = urlparse(res.headers['Location'])
            self.assertEqual('/bags/%s' % id, bag_url_v0.path)
            self.assertEqual('version=0', bag_url_v0.query)

            res = client.put(
                '/bags/%s' % id,
                data=updated_bag_jsonld,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            bag_url_v1 = urlparse(res.headers['Location'])
            self.assertEqual('/bags/%s' % id, bag_url_v1.path)
            self.assertEqual('version=1', bag_url_v1.query)

            res = client.get('/bags/%s' % id)
            self.maxDiff = None
            self.assertEqual(
                json.loads(updated_bag_jsonld),
                json.loads(res.get_data(as_text=True)))
            context = json.loads(res.get_data(as_text=True))['@context']
            self.assertEqual(context, [
                'http://localhost.localdomain:5000/c', {
                    '@base': 'http://n2t.net/ark:/99152/',
                    "foo": "http://example.org/foo"
                }])

            res = client.get('/bags/%s?version=0' % id)
            self.maxDiff = None
            self.assertEqual(
                json.loads(bag_jsonld),
                json.loads(res.get_data(as_text=True)))

            res = client.get('/bags/%s?version=1' % id)
            self.maxDiff = None
            self.assertEqual(
                json.loads(updated_bag_jsonld),
                json.loads(res.get_data(as_text=True)))
Exemplo n.º 10
0
def insert_descendant(parent_id, web_array):
    for web in web_array:
        client = datastore.Client()
        parent_key = client.key('ScrapingDataSummary', int(parent_id))
        key = client.key('ScrapingDataDetails', parent=parent_key)
        entity = datastore.Entity(key=key)
        entity['title'] = web[0]
        entity['users'] = web[1]
        entity['web_name'] = web[2]
        entity['url'] = web[3]
        client.put(entity)
    return entity
Exemplo n.º 11
0
    def test_update_bag(self):
        with open(filepath('test-bag.json')) as f:
            bag_json = f.read()
        with open(filepath('test-bag.jsonld')) as f:
            bag_jsonld = f.read()
        with open(filepath('test-bag-updated.json')) as f:
            updated_bag_json = f.read()
        with open(filepath('test-bag-updated.jsonld')) as f:
            updated_bag_jsonld = f.read()
        with self.client as client:
            id = UUID('6f2c64e2-c65f-4e2d-b028-f89dfb71ce69')
            res = client.put(
                '/bags/%s' % id,
                data=bag_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            bag_url_v0 = urlparse(res.headers['Location'])
            self.assertEqual('/bags/%s' % id, bag_url_v0.path)
            self.assertEqual('version=0', bag_url_v0.query)

            res = client.put(
                '/bags/%s' % id,
                data=updated_bag_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            bag_url_v1 = urlparse(res.headers['Location'])
            self.assertEqual('/bags/%s' % id, bag_url_v1.path)
            self.assertEqual('version=1', bag_url_v1.query)

            res = client.get('/bags/%s' % id)
            self.maxDiff = None
            self.assertEqual(
                json.loads(updated_bag_jsonld),
                json.loads(res.get_data(as_text=True)))

            res = client.get('/bags/%s?version=0' % id)
            self.maxDiff = None
            self.assertEqual(
                json.loads(bag_jsonld),
                json.loads(res.get_data(as_text=True)))

            res = client.get('/bags/%s?version=1' % id)
            self.maxDiff = None
            self.assertEqual(
                json.loads(updated_bag_jsonld),
                json.loads(res.get_data(as_text=True)))
Exemplo n.º 12
0
 def test_put_graph(self):
     with open(filepath('test-graph.json')) as f:
         graph_json = f.read()
     with self.client as client:
         id = 'places/us-states'
         res = client.put(
             '/graphs/%s' % id,
             data=graph_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
         self.assertEqual(res.status_code, http.client.CREATED)
         graph_url = urlparse(res.headers['Location'])
         self.assertEqual('/graphs/%s' % id, graph_url.path)
         self.assertEqual('version=0', graph_url.query)
         res = client.get(res.headers['Location'])
         self.assertTrue('Last-Modified' in res.headers)
         self.assertEqual(
             res.headers['Etag'],
             'W/"graph-places/us-states-version-0"')
         res = client.get('/graphs/')
         self.assertEqual(res.status_code, http.client.OK)
         data = json.loads(res.get_data(as_text=True))
         self.assertEqual(
             {'http://localhost.localdomain:5000/d/',
              'http://localhost.localdomain:5000/graphs/%s' % id},
             set(data['graphs'].keys()))
Exemplo n.º 13
0
 def test_create_bag(self):
     with open(filepath('test-bag.json')) as f:
         bag_json = f.read()
     with open(filepath('test-bag.jsonld')) as f:
         bag_jsonld = f.read()
     with self.client as client:
         id = UUID('6f2c64e2-c65f-4e2d-b028-f89dfb71ce69')
         res = client.put(
             '/bags/%s' % id,
             data=bag_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
         self.assertEqual(res.status_code, http.client.CREATED)
         bag_url = urlparse(res.headers['Location'])
         self.assertEqual('/bags/%s' % id, bag_url.path)
         self.assertEqual('version=0', bag_url.query)
         res = client.get(res.headers['Location'])
         self.assertTrue('Last-Modified' in res.headers)
         self.assertEqual(
             res.headers['Etag'],
             'W/"bag-6f2c64e2-c65f-4e2d-b028-f89dfb71ce69-version-0"')
         self.maxDiff = None
         self.assertEqual(
             json.loads(bag_jsonld),
             json.loads(res.get_data(as_text=True)))
         context = json.loads(res.get_data(as_text=True))['@context']
         self.assertEqual(context, [
             'http://localhost.localdomain:5000/c',
             {'@base': 'http://n2t.net/ark:/99152/'}])
         res = client.get('/bags/')
         self.assertEqual(res.status_code, http.client.OK)
         self.assertEqual(
             ['http://localhost.localdomain:5000/bags/%s' % id],
             json.loads(res.get_data(as_text=True)))
Exemplo n.º 14
0
 def test_update_merged_patch(self):
     with self.client as client:
         res = client.patch(
             '/d/',
             data=self.patch,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
         patch_path = urlparse(res.headers['Location']).path
         res = client.post(
             patch_path + 'merge',
             headers={'Authorization': 'Bearer '
                      + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
         res = client.put(
             patch_path + 'patch.jsonpatch',
             data=self.patch,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
     self.assertEqual(res.status_code, http.client.FORBIDDEN)
     self.assertEqual(
         res.headers['WWW-Authenticate'],
         'Bearer realm="PeriodO", error="insufficient_scope", '
         + 'error_description='
         + '"The access token does not provide sufficient privileges", '
         + 'error_uri="http://tools.ietf.org/html/rfc6750#section-6.2.3"')
Exemplo n.º 15
0
 def test_delete_graph(self):
     with open(filepath('test-graph.json')) as f:
         graph_json = f.read()
     with self.client as client:
         id = 'places/us-states'
         res = client.put(
             '/graphs/%s' % id,
             data=graph_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
         self.assertEqual(res.status_code, http.client.CREATED)
         res = client.delete(
             '/graphs/%s' % id,
             buffered=True,
             headers={'Authorization': 'Bearer '
                      + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
         self.assertEqual(res.status_code, http.client.NO_CONTENT)
         res = client.get('/graphs/%s' % id)
         self.assertEqual(res.status_code, http.client.NOT_FOUND)
         res = client.get('/graphs/%s?version=0' % id)
         self.assertEqual(res.status_code, http.client.OK)
         res = client.get('/graphs/')
         self.assertEqual(res.status_code, http.client.OK)
         data = json.loads(res.get_data(as_text=True))
         self.assertEqual(
             {'http://localhost.localdomain:5000/d/'},
             set(data['graphs'].keys()))
         res = client.put(
             '/graphs/%s' % id,
             data=graph_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
         self.assertEqual(res.status_code, http.client.CREATED)
         graph_url_v1 = urlparse(res.headers['Location'])
         self.assertEqual('/graphs/%s' % id, graph_url_v1.path)
         self.assertEqual('version=1', graph_url_v1.query)
         res = client.get('/graphs/%s' % id)
         self.assertEqual(res.status_code, http.client.OK)
         res = client.get('/graphs/%s?version=0' % id)
         self.assertEqual(res.status_code, http.client.OK)
         res = client.get('/graphs/%s?version=1' % id)
         self.assertEqual(res.status_code, http.client.OK)
Exemplo n.º 16
0
 def test_create_bag_requires_auth(self):
     with open(filepath('test-bag.json')) as f:
         bag_json = f.read()
     with self.client as client:
         id = UUID('6f2c64e2-c65f-4e2d-b028-f89dfb71ce69')
         res = client.put(
             '/bags/%s' % id,
             data=bag_json,
             content_type='application/json')
         self.assertEqual(res.status_code, http.client.UNAUTHORIZED)
Exemplo n.º 17
0
 def test_put_graph_requires_permission(self):
     with open(filepath('test-graph.json')) as f:
         graph_json = f.read()
     with self.client as client:
         id = 'places/us-states'
         res = client.put(
             '/graphs/%s' % id,
             data=graph_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
         self.assertEqual(res.status_code, http.client.FORBIDDEN)
Exemplo n.º 18
0
 def test_delete_graph_requires_auth(self):
     with open(filepath('test-graph.json')) as f:
         graph_json = f.read()
     with self.client as client:
         id = 'places/us-states'
         res = client.put(
             '/graphs/%s' % id,
             data=graph_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
         self.assertEqual(res.status_code, http.client.CREATED)
         res = client.delete('/graphs/%s' % id)
         self.assertEqual(res.status_code, http.client.UNAUTHORIZED)
Exemplo n.º 19
0
def insert(things, check):
    client = datastore.Client()
    key = client.key("Fish")
    entity = datastore.Entity(key=key)
    entity["ans0"]
    entity["ans1"]
    entity["ans2"]
    #for i in range(0,10):
    #    entity["word{i}"] =
    entity["word0"]
    entity["word1"]
    entity["word2"]
    entity["word3"]
    entity["word4"]
    entity["word5"]
    entity["word6"]
    entity["word7"]
    entity["word8"]
    entity["word9"]
    entity["created"] = datetime.now()
    client.put(entity)
    entity['id'] = entity.key.id
    return entity
Exemplo n.º 20
0
 def test_creator_patch_update(self):
     with self.client as client:
         res = client.patch(
             '/d/',
             data=self.patch,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
         res = client.put(
             urlparse(res.headers['Location']).path + 'patch.jsonpatch',
             data=self.patch,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
         self.assertEqual(res.status_code, http.client.OK)
Exemplo n.º 21
0
 def test_create_bag_requires_items_be_periodo_ids(self):
     with open(filepath('test-bag.json')) as f:
         bag_json = json.loads(f.read())
         bag_json['items'].append('foobar')
     with self.client as client:
         id = UUID('6f2c64e2-c65f-4e2d-b028-f89dfb71ce69')
         res = client.put(
             '/bags/%s' % id,
             data=json.dumps(bag_json),
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
         self.assertEqual(res.status_code, http.client.BAD_REQUEST)
         self.assertEqual(
             json.loads(res.get_data(as_text=True))['message'],
             'No resource with key: foobar')
Exemplo n.º 22
0
def test_update_product(client, product_fixture):
    product_id = product_fixture[0]
    new_description = {
        'product_description': 'New description',
    }
    response = client.put(f'/api/product/{product_id}', data=new_description)
    result = response.json

    assert http.client.OK == response.status_code
    assert result['product_description'] == 'New description'

    # The change is persistent
    response = client.get(f'/api/product/{product_id}')
    result = response.json

    assert http.client.OK == response.status_code
    assert result['product_description'] == 'New description'
Exemplo n.º 23
0
 def test_if_none_match(self):
     with open(filepath('test-bag.json')) as f:
         bag_json = f.read()
     with self.client as client:
         id = UUID('6f2c64e2-c65f-4e2d-b028-f89dfb71ce69')
         res = client.put(
             '/bags/%s' % id,
             data=bag_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'NTAwNWViMTgtYmU2Yi00YWMwLWIwODQtMDQ0MzI4OWIzMzc4'})
         self.assertEqual(res.status_code, http.client.CREATED)
         res = client.get(
             res.headers['Location'],
             buffered=True,
             headers={
                 'If-None-Match':
                 'W/"bag-6f2c64e2-c65f-4e2d-b028-f89dfb71ce69-version-0"'})
         self.assertEqual(res.status_code, http.client.NOT_MODIFIED)
Exemplo n.º 24
0
 def test_if_none_match(self):
     with open(filepath('test-graph.json')) as f:
         graph_json = f.read()
     with self.client as client:
         id = 'places/us-states'
         res = client.put(
             '/graphs/%s' % id,
             data=graph_json,
             content_type='application/json',
             headers={'Authorization': 'Bearer '
                      + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
         self.assertEqual(res.status_code, http.client.CREATED)
         res = client.get(
             res.headers['Location'],
             buffered=True,
             headers={
                 'If-None-Match':
                 'W/"graph-places/us-states-version-0"'})
         self.assertEqual(res.status_code, http.client.NOT_MODIFIED)
Exemplo n.º 25
0
def test_update_sprint(client, init_database):

    sprint0 = add_temp_sprint(1, "test description", 1, False, "01/01/2020")

    data = dict(
        user_id=1,
        description="Test correction",
        project_id=1,
        closed=False,
        end_date="01/01/2020",
    )
    url = "/sprint/update/" + str(sprint0[0])

    response = client.put(url, json=data)

    response_json = json.loads(response.data.decode("utf-8"))
    new_sprint = Sprint.query.get(response_json["id"])

    assert new_sprint.description == "Test correction"
    app.db.session.commit()
Exemplo n.º 26
0
def test_update_test(client, init_database):

    # creando story y criterias temporales asociadas
    story0 = add_temp_story("test_description", 1, StoryPriority.high, False)
    a_test0 = add_temp_accepttests(1, "Test description1", story0[0], False)

    data = dict(
        story_id=story0[0],
        description="Test correction",
        user_id=1,
    )
    url = "/test/update/" + str(a_test0[0])

    response = client.put(url, json=data)

    response_json = json.loads(response.data.decode("utf-8"))
    new_test = AcceptanceTest.query.get(response_json["id"])

    assert new_test.description == "Test correction"
    app.db.session.commit()
Exemplo n.º 27
0
    def test_group_sibling_graphs(self):
        with open(filepath('test-graph.json')) as f:
            graph_json = f.read()
        with self.client as client:
            res = client.put(
                '/graphs/places/A',
                data=graph_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            res = client.put(
                '/graphs/places/B',
                data=graph_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
            self.assertEqual(res.status_code, http.client.CREATED)
            res = client.put(
                '/graphs/not-places/C',
                data=graph_json,
                content_type='application/json',
                headers={'Authorization': 'Bearer '
                         + 'ZjdjNjQ1ODQtMDc1MC00Y2I2LThjODEtMjkzMmY1ZGFhYmI4'})
            self.assertEqual(res.status_code, http.client.CREATED)

            res = client.get('/graphs/places/')
            self.assertEqual(res.status_code, http.client.OK)
            data = json.loads(res.get_data(as_text=True))
            self.assertEqual(
                {'http://localhost.localdomain:5000/graphs/places/A',
                 'http://localhost.localdomain:5000/graphs/places/B'},
                set(data['graphs'].keys()))
            self.assertEqual(
                'http://localhost.localdomain:5000/graphs/places/',
                data['@context']['graphs']['@id'])

            res = client.get('/graphs/places.json')
            self.assertEqual(res.status_code, http.client.OK)
            data = json.loads(res.get_data(as_text=True))
            self.assertEqual(
                {'http://localhost.localdomain:5000/graphs/places/A',
                 'http://localhost.localdomain:5000/graphs/places/B'},
                set(data['graphs'].keys()))
            self.assertEqual(
                'http://localhost.localdomain:5000/graphs/places/',
                data['@context']['graphs']['@id'])

            res = client.get('/graphs/places')
            self.assertEqual(res.status_code, http.client.OK)
            data = json.loads(res.get_data(as_text=True))
            self.assertEqual(
                {'http://localhost.localdomain:5000/graphs/places/A',
                 'http://localhost.localdomain:5000/graphs/places/B'},
                set(data['graphs'].keys()))
            self.assertEqual(
                'http://localhost.localdomain:5000/graphs/places/',
                data['@context']['graphs']['@id'])
            self.assertEqual(
                res.headers['Content-Disposition'],
                'attachment; filename="periodo-graph-places.json"')

            res = client.get('/graphs/')
            self.assertEqual(res.status_code, http.client.OK)
            data = json.loads(res.get_data(as_text=True))
            self.assertEqual(
                {'http://localhost.localdomain:5000/graphs/places/A',
                 'http://localhost.localdomain:5000/graphs/places/B',
                 'http://localhost.localdomain:5000/graphs/not-places/C',
                 'http://localhost.localdomain:5000/d/'},
                set(data['graphs'].keys()))
            self.assertEqual(
                'http://localhost.localdomain:5000/graphs/',
                data['@context']['graphs']['@id'])
            self.assertEqual(
                res.headers['Content-Disposition'],
                'attachment; filename="periodo-graphs.json"')