示例#1
0
 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())
示例#2
0
 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)
示例#3
0
 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())
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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 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
示例#8
0
 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())
示例#9
0
 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)
示例#10
0
 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())
示例#11
0

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('<.*?>|&nbsp;', '', Eligibility)

    testGPA = GPA(Eligibility, ScholarshipIds[e])
    print(Eligibility)
    print(testGPA.getGPA())
    print('\n\n')
示例#12
0
 def doGPAParser(self, eligibility, scholarshipId):
     parseGPA = GPA(eligibility, scholarshipId)
     if parseGPA.getGPA() != '':
         # print(parseGPA.getGPA())
         # print(parseGPA.getScholarshipPackageRequirementFormat().getStringValue())
         return parseGPA.getScholarshipPackageRequirementFormat()
示例#13
0
 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())
示例#14
0
 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())
示例#15
0
 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)
示例#16
0
 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)
示例#17
0
    global cnxn, cursor
    cnxn = pyodbc.connect(r'Driver={SQL Server};Server=SUDB-DEV;Database=Spiderman;Trusted_Connection=yes;')
    cursor = cnxn.cursor()


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('<.*?>|&nbsp;', '', Eligibility)

    testGPA = GPA(Eligibility, ScholarshipIds[e])
    print(Eligibility)
    print(testGPA.getGPA())
    print('\n\n')
示例#18
0
 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())
    cursor = cnxn.cursor()


def GetInfoFromDatabase():
    cursor.execute("SELECT ScholarshipPackageId, Elgibility FROM dbo.DepartmentTestCases")

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)):
    print(ScholarshipIds[e])

    Eligibility = Eligibilities[e]
    Eligibility = re.sub('<.*?>|&nbsp;', '', Eligibility)
    print(Eligibility)

    parseGPA = GPA(Eligibility, ScholarshipIds[e])
    # parseMajor = Majors(Eligibility)

    print(parseGPA.getGPA())
    # print(parseMajor.getMajors())
示例#20
0
 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)
示例#21
0
 def doGPAParser(self):
     for line in self.textLines:
         parseGPA = GPA(line)
         if parseGPA.getGPA() != '':
             return parseGPA.getScholarshipPackageRequirementFormat()