Ejemplo n.º 1
0
 def get_samples():
     response_object = {'status': 'success'}
     if request.method == 'POST':
         post_data = request.get_json()
         new_sample = {
             'title': post_data.get('title'),
             'author': post_data.get('author'),
             'read': post_data.get('read')
         }
         samples.add_sample(new_sample)
         response_object['message'] = 'Sample added!'
         response_object['sample_id'] = new_sample["id"]
         log.debug('Sample added: %s ', new_sample)
     else:
         req_page = request.args.get('page', default=1, type=int)
         resp = samples.get_samples(page=req_page)
         response_object['samples'] = resp
         log.debug('Returning %d samples', len(resp))
     # log.debug('Returning samples: %s ', response_object)
     resp = jsonify(response_object)
     return resp
Ejemplo n.º 2
0
def test_delete_sample_not_avail():
    samples.add_sample(sample)
    assert not samples.delete_sample("not_found")
Ejemplo n.º 3
0
def test_delete_sample():
    samples.add_sample(sample)
    assert samples.delete_sample(sample["id"])
Ejemplo n.º 4
0
def test_update_sample_not_found():
    samples.add_sample(sample)
    assert not samples.update_sample({"id": "not_found"})
Ejemplo n.º 5
0
def test_update_sample():
    samples.add_sample(sample)
    assert samples.update_sample(sample)
Ejemplo n.º 6
0
def test_add_sample():
    assert not samples.add_sample(sample)