コード例 #1
0
ファイル: project.py プロジェクト: pberube/elastic-sandbox
 def delete(self, project_name, entry_id):
     """Delete one entry by id"""
     if validate_project_name(project_name):
         if validate_id(entry_id):
             response = elastic_controller.delete(project_name,
                                                  entry_id.upper())
         else:
             response = None, '502 Invalid Id'
     else:
         response = None, '501 Project does not exist'
     return response
コード例 #2
0
ファイル: project.py プロジェクト: pberube/elastic-sandbox
 def get(self, project_name, entry_id):
     """Find one entry by its id"""
     if validate_project_name(project_name):
         if validate_id(entry_id):
             response = elastic_controller.by_index_id(
                 project_name, 'requirements', entry_id.upper())
         else:
             response = None, '502 Invalid Id'
     else:
         response = None, '501 Project does not exist'
     return response
コード例 #3
0
ファイル: project.py プロジェクト: pberube/elastic-sandbox
 def post(self, project_name, entry_id):
     """Insert one entry"""
     if validate_project_name(project_name):
         if validate_id(entry_id):
             response = elastic_controller.add(project_name, 'requirements',
                                               entry_id.upper(),
                                               request.json)
         else:
             response = None, '502 Invalid Id'
     else:
         response = None, '501 Project does not exist'
     return response
コード例 #4
0
 def test_project_name_validation(self):
     self.assertTrue(validate_project_name('project1'))
     self.assertTrue(validate_project_name('project1_reqs'))
     self.assertFalse(validate_project_name('project'))
     self.assertFalse(validate_project_name('project2'))