示例#1
0
 def put(self, uuid):
     if utils.is_file(products_json_file):
         results = atomic.update_item(str(products_json_file), request.json,
                                      str(uuid))
         if results:
             return results, 200
     return {"message": "Product not found."}, 404
示例#2
0
 def get(self, uuid):
     if utils.is_file(products_json_file):
         results = atomic.get_item(str(products_json_file), str(uuid))
         if results:
             return results, 200
     return {"message": "Product not found."}, 404
示例#3
0
 def post(self):
     """Creates a new product."""
     if utils.is_file(products_json_file):
         result = atomic.set_item(str(products_json_file), request.json)
         if result:
             return {"message": "Product successfully created."}, 201
示例#4
0
def test_is_file_not_ok():
    invalid_filename = "tests/data.json"
    assert not utils.is_file(invalid_filename)
示例#5
0
def test_is_file_ok():
    invalid_filename = "tests/test_main.py"
    assert utils.is_file(invalid_filename)