Ejemplo n.º 1
0
 def test100_040_ShouldConstructFixWithExistingFile(self):
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     try:
         theLogFile = open(self.RANDOM_LOG_FILE, 'r')
         numberOfExpectedEntries = 2
         for _ in range(numberOfExpectedEntries):
             entry = theLogFile.readline()
             self.assertNotEquals(-1, entry.find(self.logStartString), 
                                  "Minor:  first line of log is incorrect")
     except IOError:
         self.fail()
     self.assertIsInstance(theFix, F.Fix, 
                           "Major:  log file failed to create")
     self.deleteNamedLogFlag = True
Ejemplo n.º 2
0
 def test300_040_ShouldLogMultipleSightingsInTimeOrder(self):       
     testFile = "CA02_300_ValidMultipleStarSighting.xml"
     targetStringList = [
         ["Sirius", "2016-03-01", "00:05:05"],
         ["Canopus", "2016-03-02", "23:40:01"]
         ]
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     theFix.setSightingFile(testFile)
     theFix.getSightings()
     
     theLogFile = open(self.RANDOM_LOG_FILE, "r")
     logFileContents = theLogFile.readlines()
     theLogFile.close()
     
     # find entry with first star
     entryIndex = self.indexInList(targetStringList[0][0], logFileContents)
     self.assertLess(-1, entryIndex, 
         "Major: failure to find " + targetStringList[0][0] +  " in log")
  
     for targetString in targetStringList:
         if not (targetString[0] in logFileContents[entryIndex]):
             self.fail("failure to find {} in log".format(targetString[0]))
         entryIndex += 1
  
     self.deleteNamedLogFlag = True  
Ejemplo n.º 3
0
 def test200_960_SholdRaiseExceptionOnMissingFile(self):
     expectedDiag = self.className + "setSightingFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile(self.RANDOM_LOG_FILE+".xml")
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Minor:  failure to check for missing sighting file") 
Ejemplo n.º 4
0
 def test200_930_ShouldRaiseExceptionOnNonXmlFile1(self):
     expectedDiag = self.className + "setSightingFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile("sighting.")
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Minor:  failure to check for non.xml sighting file extension")
Ejemplo n.º 5
0
 def test200_940_ShouldRaiseExceptionOnNonXmlFile2(self):
     expectedDiag = self.className + "setSightingFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile("xml")
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Minor:  failure to delineate between sighting file name and extension") 
Ejemplo n.º 6
0
 def test200_920_ShouldRaiseExceptionOnFileLengthError(self):
     expectedDiag = self.className + "setSightingFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile(".xml")
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Minor:  failure to check for .GE. 1 sighting file name") 
Ejemplo n.º 7
0
 def test200_910_ShouldRaiseExceptionOnNonStringFileName(self):
     expectedDiag = self.className + "setSightingFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile(42)
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Minor:  failure to check for non-string sighting file name")  
Ejemplo n.º 8
0
 def test300_910_ShouldRaiseExceptionOnNotSettingSightingsFile(self):
     expectedDiag = self.className + "getSightings:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.getSightings()
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Major:  failure to set sighting file before getSightings()")   
Ejemplo n.º 9
0
 def test100_025_ShouldConstructWithKeywordParm(self):
     try:
         theFix = F.Fix(logFile=self.RANDOM_LOG_FILE)
         self.assertTrue(True)
     except Exception as e:
         self.fail("Major: " + str(e))
     self.deleteNamedLogFlag = True
Ejemplo n.º 10
0
 def test300_920_ShouldRaiseExceptionOnMissingMandatoryTag(self):
     expectedDiag = self.className + "getSightings:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile("CA02_300_InvalidWithMissingMandatoryTags.xml")
         theFix.getSightings()
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Major:  failure to check for missing mandatory tag")   
Ejemplo n.º 11
0
 def test300_995_ShouldRaiseExceptionOnInvalidHorizon(self):
     expectedDiag = self.className + "getSightings:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile("CA02_300_InvalidHorizon.xml")
         theFix.getSightings()
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Minor:  failure to check for invalid horizon" )
Ejemplo n.º 12
0
 def test300_010_ShouldIgnoreMixedIndentation(self):
     testFile = "CA02_300_GenericValidStarSightingFile.xml"
     expectedResult = ("0d0.0", "0d0.0")
     theFix = F.Fix()
     theFix.setSightingFile(testFile)
     result = theFix.getSightings()
     self.assertTupleEqual(expectedResult, result, 
                           "Minor:  incorrect return value from getSightings")
Ejemplo n.º 13
0
 def test200_010_ShouldConstructWithKeywordParm(self):
     'Minor:  '
     theFix = F.Fix(logFile=self.RANDOM_LOG_FILE)
     try:
         result = theFix.setSightingFile("CA02_200_ValidStarSightingFile.xml")
         self.assertEquals(result, "CA02_200_ValidStarSightingFile.xml")
     except:
         self.fail("Minor: incorrect keyword specified in setSighting parm")
     self.deleteNamedLogFlag = True 
Ejemplo n.º 14
0
 def test200_020_ShouldSetValidSightingFile(self):
     theFix = F.Fix()
     result = theFix.setSightingFile("CA02_200_ValidStarSightingFile.xml")
     self.assertEquals(result,"CA02_200_ValidStarSightingFile.xml")
     theLogFile = open(self.DEFAULT_LOG_FILE, "r")
     logFileContents = theLogFile.readlines()
     self.assertNotEquals(-1, logFileContents[-1].find(self.logSightingString), 
                          "Minor:  first setSighting logged entry is incorrect")
     theLogFile.close()
Ejemplo n.º 15
0
 def test300_020_ShouldIgnoreMixedIndentation(self):
     testFile = "CA02_300_ValidWithMixedIndentation.xml"
     theFix = F.Fix()
     theFix.setSightingFile(testFile)
     try:
         theFix.getSightings()
         self.assertTrue(True)
     except:
         self.fail("Major: getSightings failed on valid file with mixed indentation")  
Ejemplo n.º 16
0
 def test100_020_ShouldConstructFixWithDefaultFile(self):
     theFix = F.Fix()
     try:
         theLogFile = open(self.DEFAULT_LOG_FILE, 'r')
         entry = theLogFile.readline()
         self.assertNotEquals(-1, entry.find("Start of log"), 
                              "Minor:  first line of log is incorrect")
     except IOError:
         self.fail()
     self.assertIsInstance(theFix, F.Fix, 
                           "Major:  log file failed to create")
Ejemplo n.º 17
0
 def test100_030_ShouldConstructFixWithNamedFile(self):
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     try:
         theLogFile = open(self.RANDOM_LOG_FILE, 'r')
         entry = theLogFile.readline()
         del theLogFile
         self.assertNotEquals(-1, entry.find(self.logStartString), 
                              "Minor:  first line of log is incorrect")
     except IOError:
         self.fail()
     self.assertIsInstance(theFix, F.Fix, "Major:  log file failed to create")
     self.deleteNamedLogFlag = True
Ejemplo n.º 18
0
 def test300_090_ShouldLogStarWithDefaultSightingValues(self):
     testFile = "CA02_300_ValidOneStarWithDefaultValues.xml"
     targetStringList = ["Hadar", "2016-03-01", "23:40:01", "29d59.9"]
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     theFix.setSightingFile(testFile)
     theFix.getSightings()
     
     theLogFile = open(self.RANDOM_LOG_FILE, "r")
     logFileContents = theLogFile.readlines()
     theLogFile.close()
     
     sightingCount = 0
     for logEntryNumber in range(0, len(logFileContents)):
         if(logFileContents[logEntryNumber].find(targetStringList[0]) > -1):
             sightingCount += 1
             for target in targetStringList:
                 self.assertNotEquals(-1, logFileContents[logEntryNumber].find(target), 
                                      "Major:  Log entry is not correct for getSightings")
     self.assertEquals(1, sightingCount)
     self.deleteNamedLogFlag = True
Ejemplo n.º 19
0
 def test300_060_ShouldHandleNoSightings(self):       
     testFile = "CA02_300_ValidWithNoSightings.xml"
     targetString1 = "End of sighting file"
     targetString2 = "Start of sighting file"
     
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     theFix.setSightingFile(testFile)
     theFix.getSightings()
     
     theLogFile = open(self.RANDOM_LOG_FILE, "r")
     logFileContents = theLogFile.readlines()
     theLogFile.close()
     
     endOfSightingFileIndex = self.indexInList(targetString1, logFileContents)
     self.assertLess(-1,endOfSightingFileIndex,
                        "Major: log file does not contain 'end of sighting file' entry")
     self.assertLess(1, endOfSightingFileIndex,
                        "Major: log file does not contain sufficient entries")
     self.assertTrue((targetString2 in logFileContents[endOfSightingFileIndex - 1]))
     self.deleteNamedLogFlag = True 
Ejemplo n.º 20
0
 def test300_070_ShouldIgnoreExtraneousTags(self):       
     testFile = "CA02_300_ValidWithExtraneousTags.xml"
     targetStringList = [
         ["Sirius", "2016-03-01", "00:05:05"],
         ]
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     theFix.setSightingFile(testFile)
     theFix.getSightings()
     
     theLogFile = open(self.RANDOM_LOG_FILE, "r")
     logFileContents = theLogFile.readlines()
     theLogFile.close()
     
     # find entry with first star
     entryIndex = self.indexInList(targetStringList[0][0], logFileContents)
     self.assertLess(-1, entryIndex, 
                        "Major: failure to find " + targetStringList[0][0] +  " in log")
     for index in range(entryIndex+1, len(targetStringList)):
         entryIndex += 1
         if(not(targetStringList[index][0] in logFileContents[entryIndex])):
             self.fail("Major: failure to find star in log")
     self.deleteNamedLogFlag = True
Ejemplo n.º 21
0
 def test300_050_ShouldLogMultipleSightingsWithSameDateTime(self):       
     testFile = "CA02_300_ValidMultipleStarSightingSameDateTime.xml"
     targetStringList = [
         ["Acrux", "2016-03-01", "00:05:05"],
         ["Sirius", "2016-03-01", "00:05:05"],
         ["Canopus", "2016-03-02", "23:40:01"]
         ]
     theFix = F.Fix(self.RANDOM_LOG_FILE)
     theFix.setSightingFile(testFile)
     theFix.getSightings()
     
     theLogFile = open(self.RANDOM_LOG_FILE, "r")
     logFileContents = theLogFile.readlines()
     theLogFile.close()
     
     # find entry with first star
     entryIndex = self.indexInList(targetStringList[0][0], logFileContents)
     self.assertLess(-1, entryIndex, 
                        "Major: failure to find " + targetStringList[0][0] +  " in log")
     for index in range(entryIndex+1, len(targetStringList)):
         entryIndex += 1
         if(not(targetStringList[index][0] in logFileContents[entryIndex])):
             self.fail("Major: failure to find star in log")
     self.deleteNamedLogFlag = True 
Ejemplo n.º 22
0
 def test100_910_ShouldRaiseExceptionOnFileNameLength(self):
     expectedDiag = self.className + "__init__:"
     with self.assertRaises(ValueError) as context:
         F.Fix("")
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)], 
                       "Minor:  failure to check for log file name length")  
Ejemplo n.º 23
0
 def test100_010_ShouldConstructFix(self):
     'Fix.__init__'
     self.assertIsInstance(F.Fix(), F.Fix, 
                           "Major error:  Fix not created")
Ejemplo n.º 24
0
import Navigation.prod.fix as fix
theFix = fix.Fix()
#l=theFix.__init__("log3.txt")
k = theFix.setSightingFile("sightings.xml")
#approximatePosition = theFix.getSightings()
#fix2=logFile.logFile()
#l=theFix.Fix.__init__Fix("C:\\Users\ChandrashekarChary\\Desktop\\fold\\log.txt")
m = theFix.getSightings()
Ejemplo n.º 25
0
 def test100_920_ShouldRaiseExceptionOnNonStringFile(self):
     expectedDiag = self.className + "__init__:"
     with self.assertRaises(ValueError) as context:
         F.Fix(42)
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)], 
                       "Minor:  failure to check for non-string log file name")