def test_GPAfailure(self): failgpa = GPA("This is not the GPA you're looking for 7.4", '1') self.assertIsNotNone(failgpa) self.assertEqual( True, failgpa.checkContext('gpa|grade\spoint\saverage|maintain')) self.assertNotEqual('7.4', failgpa.getGPA()) self.assertEqual('', failgpa.getGPA())
def test_GPAvsDollarSign(self): testGPANoDollarSign = GPA('$3.50 is money, but 3.49 is a GPA', '1') self.assertIsNotNone(testGPANoDollarSign) self.assertEqual( True, testGPANoDollarSign.checkContext( 'gpa|grade\spoint\saverage|maintain')) self.assertNotEqual('3.50', testGPANoDollarSign.getGPA()) self.assertEqual('3.49', testGPANoDollarSign.getGPA())
def test_updateLogicGroup(self): testUpdateLogicGroup = GPA( 'Undergraduates must have a 3.0 GPA, while graduate students must have a 3.25', '5') self.assertIsNotNone(testUpdateLogicGroup) testUpdateLogicGroup.getGPA() self.assertEqual('1', testUpdateLogicGroup.logicGroup) test_SPRFLogicGroup = testUpdateLogicGroup.getScholarshipPackageRequirementFormat( ) self.assertEqual('1', test_SPRFLogicGroup.logicGroup)
def getGPAFromSentences(self, sentences): gpa = [] for sentence in sentences: if len(sentence) <= 1000: maybeGPA = GPA(sentence).getGPA() if maybeGPA != '': gpa.append(maybeGPA) gpa = list(set(gpa)) gpa = ', '.join(gpa) return gpa
def test_GPAWithoutGPAKeywords(self): testGPANoKeywords = GPA('Must have a 3.80', '5') self.assertIsNotNone(testGPANoKeywords) self.assertEqual( False, testGPANoKeywords.checkContext( 'gpa|grade\spoint\saverage|maintain')) self.assertEqual( False, testGPANoKeywords.checkContext( 'million|billion|trillion|version|dollar|pound|euro')) self.assertEqual('3.80', testGPANoKeywords.getGPA()) failGPANoKeywords = GPA('Must have 3.80 million dollars', '5') self.assertIsNotNone(failGPANoKeywords) self.assertEqual( False, failGPANoKeywords.checkContext( 'gpa|grade\spoint\saverage|maintain')) self.assertEqual( True, failGPANoKeywords.checkContext( 'million|billion|trillion|version|dollar|pound|euro')) self.assertEqual('', failGPANoKeywords.getGPA())
def test_GPACreateSPRFClass(self): testSPRFforGPA = GPA( 'This is to test the SPRF function for the grade point average of 2.9', '1543') self.assertIsNotNone(testSPRFforGPA) self.assertEqual( True, testSPRFforGPA.checkContext('gpa|grade\spoint\saverage|maintain')) self.assertEqual('2.9', testSPRFforGPA.getGPA()) self.assertIsNotNone( testSPRFforGPA.getScholarshipPackageRequirementFormat()) test_SPRF = testSPRFforGPA.getScholarshipPackageRequirementFormat() self.assertEqual('1543', test_SPRF.scholarshipPackageId) self.assertEqual('1', test_SPRF.attributeId) self.assertEqual('>=', test_SPRF.requirementType) self.assertEqual('2.9', test_SPRF.requirementValue) self.assertEqual('0', test_SPRF.logicGroup)
def test_verifyMaintains(self): testOfMaintain = GPA('Must maintain a $3.0 gpa', '5') self.assertIsNotNone(testOfMaintain) self.assertEqual("", testOfMaintain.getGPA()) testOfMaintain = GPA('Must maintain a 3.5', '5') self.assertIsNotNone(testOfMaintain)
def test_verifyMaintains(self): testOfMaintain = GPA('Must maintain a 3.0 gpa', '5') self.assertIsNotNone(testOfMaintain) testOfMaintain = GPA('Must maintain a 3.5', '5') self.assertIsNotNone(testOfMaintain)
def test_GPA(self): testgpa = GPA('The GPA is 3.159 not 5.304', '1') self.assertIsNotNone(testgpa) self.assertEqual( True, testgpa.checkContext('gpa|grade\spoint\saverage|maintain')) self.assertEqual('3.159', testgpa.getGPA())
def doGPAParser(self, eligibility, scholarshipId): parseGPA = GPA(eligibility, scholarshipId) if parseGPA.getGPA() != '': # print(parseGPA.getGPA()) # print(parseGPA.getScholarshipPackageRequirementFormat().getStringValue()) return parseGPA.getScholarshipPackageRequirementFormat()
def GetInfoFromDatabase(): cursor.execute( "SELECT ScholarshipPackageId, Elgibility FROM dbo.DepartmentTestCases WHERE AttributeId =1 OR AttributeId =364" ) ConnectToTheDatabase() GetInfoFromDatabase() Eligibilities = [] ScholarshipIds = [] while 1: row = cursor.fetchone() if not row: break Eligibilities.append(row.Elgibility) ScholarshipIds.append(row.ScholarshipPackageId) for e in range(len(Eligibilities)): Eligibility = Eligibilities[e] print(ScholarshipIds[e]) Eligibility = Eligibilities[e] Eligibility = re.sub('<.*?>| ', '', Eligibility) testGPA = GPA(Eligibility, ScholarshipIds[e]) print(Eligibility) print(testGPA.getGPA()) print('\n\n')