def get(self, function): """ function for get request via api Parameters ---------- function : str name of called function """ if request.args: args = request.args if function == 'create_project': print('this is the function to create a project: ' + args['project_name']) project.create_project(args['project_name']) print('this is the function to create a project: ' + args['project_name']) if function == 'get_project': return project.get_project() if function == 'get_project_files': return project.get_project_files(args['project_name']) if function == 'get_file': project.get_file(args['project_name'], args['filename']) print('this funciton parameteres: ' + args['filename']) if function == 'delete_project': project.delete_project(args['project_name']) return 201
def test_create_project(self): """Make sure it creates a project.""" create_project(project_id='001', project_description='This could be the same.') p = Project.select().where(Project.project_id == '001') q = Project.delete().where(Project.project_id == '001') q.execute() self.assertEqual(str(p), ("<class 'models.Project'> SELECT `t1`.`id`," " `t1`.`project_id`, `t1`.`project_description` " "FROM `project` AS t1 WHERE (`t1`.`project_id` = %s) " "['001']"))
def test_create_project_no_duplicate(self): """Make sure you can't create projects with duplicate IDs.""" create_project(project_id='001', project_description='Testing purpose.') from peewee import IntegrityError with self.assertRaises(IntegrityError): create_project(project_id='001', project_description='This could be the same.') # Delete the instance created q = Project.delete().where(Project.project_id == '001') q.execute()
def prompt_system_choices(): print("\n" * 3, "Select your choice: ") print("\t" * 2, "1- View all projects") print("\t" * 2, "2- Create a project") print("\t" * 2, "3- Edit a project") print("\t" * 2, "4- Delete a project") choice = input("") if choice.isdigit() and int(choice) in [1, 2, 3, 4]: if int(choice) == 1: project.print_all_projects(projects_file_path) elif int(choice) == 2: project.create_project(projects_file_path) elif int(choice) == 3: project.edit_project(projects_file_path) elif int(choice) == 4: project.delete_project(projects_file_path) print("\n" * 3) prompt_system_choices() else: print("\n" * 3) print("Enter valid choice!") prompt_auth_choices()
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. # # Copyright (c) 2014-2015, Lars Asplund [email protected] from vunit import VUnit from project import create_project ui = VUnit.from_argv() create_project(ui) ui.main()
def test_create_project_no_arguments(self): """Attempt to create a project, but fail if not nullable arguments are missing.""" with self.assertRaises(TypeError): create_project()