Пример #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)