Example #1
0
 def test_write_technique(self):
   """Check if a technique file is written in the correct path from its metadata"""
   ncf.write_technique(self.technique_metadata, os.path.realpath("write_test"))
   result = os.path.exists(os.path.realpath(os.path.join("write_test", "50_techniques", self.technique_metadata['bundle_name'], self.technique_metadata['bundle_name']+".cf")))
   # Clean
   shutil.rmtree(os.path.realpath(os.path.join("write_test", "50_techniques")))
   self.assertTrue(result)
Example #2
0
 def test_delete_technique(self):
   """Check if a technique file is correctly deleted"""
   ncf.write_technique(self.technique_metadata, os.path.realpath("write_test"))
   ncf.delete_technique(self.technique_metadata['bundle_name'], os.path.realpath("write_test"))
   result = not os.path.exists(os.path.realpath(os.path.join("write_test", "50_techniques", self.technique_metadata['bundle_name'])))
   # Clean
   shutil.rmtree(os.path.realpath(os.path.join("write_test", "50_techniques")))
   self.assertTrue(result)
Example #3
0
 def test_write_technique(self):
     """Check if a technique file is written in the correct path from its metadata"""
     ncf.write_technique(self.technique_metadata,
                         os.path.realpath("write_test"))
     result = os.path.exists(
         os.path.realpath(
             os.path.join("write_test", "50_techniques",
                          self.technique_metadata['bundle_name'],
                          self.technique_metadata['bundle_name'] + ".cf")))
     # Clean
     shutil.rmtree(
         os.path.realpath(os.path.join("write_test", "50_techniques")))
     self.assertTrue(result)
Example #4
0
 def test_delete_technique(self):
     """Check if a technique file is correctly deleted"""
     ncf.write_technique(self.technique_metadata,
                         os.path.realpath("write_test"))
     ncf.delete_technique(self.technique_metadata['bundle_name'],
                          os.path.realpath("write_test"))
     result = not os.path.exists(
         os.path.realpath(
             os.path.join("write_test", "50_techniques",
                          self.technique_metadata['bundle_name'])))
     # Clean
     shutil.rmtree(
         os.path.realpath(os.path.join("write_test", "50_techniques")))
     self.assertTrue(result)
Example #5
0
File: views.py Project: fanf/ncf
def create_technique():
  # Get data in JSON
  # technique is a mandatory parameter, abort if not present
  if not "technique" in request.json:
    return jsonify( { 'error' : "No Technique metadata provided in the request body." } ), 400
  else:
    technique = request.json['technique']

  if "path" in request.json:
    path = request.json['path']
  else:
    path = ""

  try:
    ncf.write_technique(technique,path)
  except ncf.NcfError, ex:
    return jsonify( { 'error' : ex.message } ), 500
Example #6
0
File: views.py Project: DINKIN/ncf
def create_technique():
  """ Get data in JSON """
  try:
    # technique is a mandatory parameter, abort if not present
    if not "technique" in request.json:
      return format_error(ncf.NcfError("No Technique metadata provided in the request body."), "", 400)
    else:
      technique = request.json['technique']
  
    if "path" in request.json and request.json['path'] != "":
      path = request.json['path']
    else:
      path = default_path
  
    ncf.write_technique(technique,path)
    return jsonify({ "data": technique }), 201

  except Exception as e:
    return format_error(e, "technique writing", 500)
Example #7
0
def create_technique():
    """ Get data in JSON """
    try:
        # technique is a mandatory parameter, abort if not present
        if not "technique" in request.json:
            return format_error(
                ncf.NcfError(
                    "No Technique metadata provided in the request body."), "",
                400)
        else:
            technique = request.json['technique']

        if "path" in request.json and request.json['path'] != "":
            path = request.json['path']
        else:
            path = default_path

        ncf.write_technique(technique, path)
        return jsonify({"data": technique}), 201

    except Exception as e:
        return format_error(e, "technique writing", 500)