コード例 #1
0
    def reprioritizeFeatureRequestService(self, featureRequestApp):
        print("Inside reprioritize Feature Request Service")
        # dbsession variable gets session from class function getSession()
        dbsession = self.getSession()
        updateStart = int(featureRequestApp.clientPriority)
        updateClient = featureRequestApp.client
        # Filter total rows according to given Client name
        totalRows = len(
            dbsession.query(FeatureRequestApp).filter_by(
                client=updateClient).all())
        # Checking whether given client priority less than or equal to total rows
        if updateStart <= totalRows:
            # Running for loop according to client Priority
            for updateStart in range(updateStart, totalRows + 1, 1):
                updateRow = dbsession.query(FeatureRequestApp).filter_by(
                    clientPriority=updateStart, client=updateClient).first()
                updateRow.clientPriority = updateStart + 1

            dbsession.add(featureRequestApp)
            dbsession.commit()
        # if given priority is greater than total number of rows then update as total+1 in client priority
        else:
            dbsession.add(
                FeatureRequestApp(featureRequestApp.title,
                                  featureRequestApp.description,
                                  featureRequestApp.client, totalRows + 1,
                                  featureRequestApp.targetDate,
                                  featureRequestApp.productArea))
            dbsession.commit()
コード例 #2
0
 def test_app_featureRequestService_createFeatureRequestService(self):
     """Tests successful submission of values in Feature Requests Form Page"""
     # Create an instance of MagicMock class with specification Session Class which gives a 'mock'Session instance
     mock = MagicMock(Config.Session())
     print("inside Mock test Feature request service", mock)
     # Creating an instance of FeatureRequestService class
     frs = featureRequestService.FeatureRequestService()
     # setting a mock session using setSession function in FeatureRequestService class
     frs.setSession(mock)
     print("mock set", frs.getSession())
     # Creating an instance of FeatureRequestApp model class with all required values
     fra = FeatureRequestApp('Titl5', 'descr', 'Client B', 1, 'Billing',
                             '2018-02-01')
     result = frs.createFeatureRequestService(fra)
     self.assertEqual(result, 'success')
コード例 #3
0
 def createFeatureRequestManager():
     # Instance of FeatureRequestService class is created to accesss function createFeatureRequestService
     featureRequestserviceInstance = FeatureRequestService()
     if request.method == 'POST':
         # Assigning FeatureRequestApp class object with title, description, client, clientPriority, targetData and productArea json values as arguments to createFeatureRequestService function
         # Response from createFeatureRequestService is assigned to 'result'
         result = featureRequestserviceInstance.createFeatureRequestService(
             FeatureRequestApp(request.json['title'],
                               request.json['description'],
                               request.json['client'],
                               request.json['clientPriority'],
                               request.json['targetDate'],
                               request.json['productArea']))
         # Returns a String response
         return result
コード例 #4
0
 def createFeatureRequestManager():
     # Instance of FeatureRequestService class is created to accesss functions createFeatureRequestService
     featurerequestservice = featureRequestService.FeatureRequestService(
     )
     print("Inside Create")
     if request.method == 'POST':
         # Createing a FeatureRequestApp class object with title, description, client, clientPriority, targetData and productArea as arguments
         featureRequestApp = FeatureRequestApp(
             request.json['title'], request.json['description'],
             request.json['client'], request.json['clientPriority'],
             request.json['targetDate'], request.json['productArea'])
         # Response from createFeatureRequestService is assigned to 'result'
         result = featurerequestservice.createFeatureRequestService(
             featureRequestApp)
         # Returns a String response
         return result
コード例 #5
0
 def test_app_featureRequestService_createFeatureRequestService_failure(
         self):
     """Tests successful submission of values in Feature Requests Form Page"""
     # Create an instance of MagicMock class with specification Session Class which gives a 'mock'Session instance
     mock = MagicMock(Config.Session())
     print("inside Mock test Feature request service", mock)
     # Creating an instance of FeatureRequestService class
     servicerequest = featureRequestService.FeatureRequestService()
     # setting a mock session using setSession function in FeatureRequestService class
     servicerequest.setSession(mock)
     print("mock set", servicerequest.getSession())
     # Creating an instance of FeatureRequestApp model class with invalidvalues
     insertrequestdata = FeatureRequestApp('TestTitle1', 'TestDesc1',
                                           'Client A', 'invalidvalue',
                                           'Policies', '2018-03-02')
     result = servicerequest.createFeatureRequestService(insertrequestdata)
     self.assertEqual(result, 'Error Occured')
コード例 #6
0
    def createFeatureRequestService(self, featureRequestApp):
        try:
            print("Inside Create")
            # dbsession variable gets session from class function getSession()
            dbsession = self.getSession()
            updateStart = int(featureRequestApp.clientPriority)
            updateClient = featureRequestApp.client
            # Getting total table count
            if len(dbsession.query(FeatureRequestApp).all()) > 0:
                # Filter total rows according to given Client name
                totalRows = len(
                    dbsession.query(FeatureRequestApp).filter_by(
                        client=updateClient).all())
                # Checking whether title exists. If title(Unique) exists raise message title already exists.
                self.reprioritizeFeatureRequestService(featureRequestApp,
                                                       totalRows)
            else:
                # Else FeatureRequests for a particular client are empty then this FeatureRequest is considered and First Priority and is added to the particular client
                featureapprequest = FeatureRequestApp(
                    featureRequestApp.title, featureRequestApp.description,
                    featureRequestApp.client, 1, featureRequestApp.targetDate,
                    featureRequestApp.productArea)
                dbsession.add(featureapprequest)
                dbsession.commit()
            return 'success'

        except IntegrityError as ie:
            dbsession.rollback()
            print("Title name already exists.Please change name.", ie)
            return 'Title name already exists.Please change name.'

        except psycopg2.IntegrityError as pie:
            dbsession.rollback()
            print("Title name already exists.Please change name.", pie)
            print("Inside pie")
            return 'Title name already exists.Please change name.'

        except Exception as e:
            dbsession.rollback()
            print("Error Occured in createFeatureRequestService", e)
            return 'Error Occured'

        finally:
            dbsession.close_all()
コード例 #7
0
    def createFeatureRequestService(self, featureRequestApp):
        try:
            print("Inside Create Feature Request Service")
            # dbsession variable gets session from class function getSession()
            dbsession = self.getSession()
            # Checking if any rows available in database or not
            if len(dbsession.query(FeatureRequestApp).all()) > 0:
                # For Reprioritizing client priority
                self.reprioritizeFeatureRequestService(featureRequestApp)
            else:
                # Else FeatureRequests for a particular client are empty then this FeatureRequest is considered and First Priority and is added to the particular client
                dbsession.add(
                    FeatureRequestApp(featureRequestApp.title,
                                      featureRequestApp.description,
                                      featureRequestApp.client, 1,
                                      featureRequestApp.targetDate,
                                      featureRequestApp.productArea))
                dbsession.commit()
            # Returns a String Response
            return 'success'

        except IntegrityError as ie:
            dbsession.rollback()
            print("Title name already exists.Please change name.", ie)
            return 'Title name already exists.Please change name.'

        except psycopg2.IntegrityError as pie:
            dbsession.rollback()
            print("Title name already exists.Please change name.", pie)
            print("Inside pie")
            return 'Title name already exists.Please change name.'

        except Exception as e:
            dbsession.rollback()
            print("Error Occured in createFeatureRequestService", e)
            return 'Error Occured'

        finally:
            dbsession.close_all()