コード例 #1
0
 def test500_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")   
コード例 #2
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.cleanup()
コード例 #3
0
 def test500_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")
コード例 #4
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()")
コード例 #5
0
ファイル: myFixTest2.py プロジェクト: lzs0070/wbd
 def test400_940_ShouldRaiseExceptionOnNonTxtFile1(self):
     expectedDiag = self.className + "setStarFile:"
     theFix = Fix.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setStarFile("star.")
     self.assertEquals(
         expectedDiag, context.exception.args[0][0:len(expectedDiag)],
         "Minor:  failure to check for non.xml star file extension")
コード例 #6
0
ファイル: myFixTest2.py プロジェクト: lzs0070/wbd
 def test400_910_SholdRaiseExceptionOnMissingFileName(self):
     expectedDiag = self.className + "setStarFile:"
     theFix = Fix.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setStarFile()
     self.assertEquals(expectedDiag,
                       context.exception.args[0][0:len(expectedDiag)],
                       "Major:  failure to check for missing star file")
コード例 #7
0
 def test500_990_ShouldRaiseExceptionOnInvalidPressure(self):
     expectedDiag = self.className + "getSightings:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setSightingFile("CA02_300_InvalidPressure.xml")
         theFix.getSightings()
     self.assertEquals(expectedDiag, context.exception.args[0][0:len(expectedDiag)],
                       "Major:  failure to check for invalid body" )
コード例 #8
0
ファイル: FixTest03.py プロジェクト: WenyuZhu/wbd
 def test400_930_ShouldRaiseExceptionOnNonTXTFile1(self):
     expectedDiag = self.className + "setStarFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setStarFile("sighting.")
     self.assertEquals(expectedDiag,
                       context.exception.args[0][0:len(expectedDiag)])
     os.remove(self.DEFAULT_LOG_FILE)
コード例 #9
0
ファイル: FixTest.py プロジェクト: Eclat001/wbd
 def test100_030_ShouldWriteStartLogToLogFile(self):
     aF = F.Fix("normal.txt")
     with open(aF.logFile, 'r') as f:
         lines = f.readlines()
         last_line = lines[-1]
     f.close()
     expectedLine = aF.message("Log file:\t" + os.path.abspath(aF.logFile))
     self.assertEquals(last_line, expectedLine)
コード例 #10
0
ファイル: FixTest.py プロジェクト: lzs0070/wbd
 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")
コード例 #11
0
ファイル: FixTest.py プロジェクト: lzs0070/wbd
 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")
コード例 #12
0
ファイル: FixTest.py プロジェクト: lzs0070/wbd
 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")
コード例 #13
0
ファイル: FixTest03.py プロジェクト: WenyuZhu/wbd
 def test400_940_SholdRaiseExceptionOnMissingFileName(self):
     expectedDiag = self.className + "setStarFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setStarFile('missing.txt')
     self.assertEquals(expectedDiag,
                       context.exception.args[0][0:len(expectedDiag)])
     os.remove(self.DEFAULT_LOG_FILE)
コード例 #14
0
ファイル: FixTest03.py プロジェクト: WenyuZhu/wbd
 def test300_920_ShouldRaiseExceptionOnFileLengthError(self):
     expectedDiag = self.className + "setAriesFile:"
     theFix = F.Fix()
     with self.assertRaises(ValueError) as context:
         theFix.setAriesFile(".txt")
     self.assertEquals(expectedDiag,
                       context.exception.args[0][0:len(expectedDiag)])
     os.remove(self.DEFAULT_LOG_FILE)
コード例 #15
0
def main():
    myFix = Fix.Fix()
    myFix.setSightingFile("f4.xml")
    print("Start")
    approxPos = myFix.getSightings()
    
    print approxPos
    print("End")
コード例 #16
0
ファイル: FixTest.py プロジェクト: lzs0070/wbd
 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)],
         "Major:  failure to check for missing sighting file")
コード例 #17
0
ファイル: FixTestCA05.py プロジェクト: lzz0019/wbd
 def test300_020_ShouldReturnTupleOfApproximateLocation(self):
     theFix = F.Fix()
     theFix.setSightingFile("CA05_300_ValidSightingFile.xml")
     theFix.setStarFile("CA03_Valid_Stars.txt")
     theFix.setAriesFile("CA03_Valid_Aries.txt")
     result = theFix.getSightings("N27d59.5", "85d33.4")
     expectedResult = ("S20d15.5", "79d19.9")
     self.assertTupleEqual(result, expectedResult)
コード例 #18
0
ファイル: FixTest.py プロジェクト: lzs0070/wbd
 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"
     )
コード例 #19
0
ファイル: FixTest05.py プロジェクト: ajbstewart/wbd
 def test100_030_LatitudeShouldReturnDefaultWithoutParameter(self):
     expectedLat = "0d0.0"
     aFix = Fix.Fix('testLogCA05.txt')
     aFix.setSightingFile('sightingFileCA05.xml')
     aFix.setStarFile("stars.txt")
     aFix.setAriesFile("aries.txt")
     aFix.getSightings()
     actualLat = aFix.assumedLat
     self.assertEquals(expectedLat, actualLat)
コード例 #20
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()
コード例 #21
0
 def test200_020_ShouldWriteEntryToLogFile(self):
     fixInstance=Fix.Fix()
     fixInstance.setSightingFile("2.xml")
     logFileName=fixInstance.logFileName
     for line in reversed(open(logFileName).readlines()):
         string=line.rstrip()
         break
     expectedString="Sighting file:"+"\t"+os.path.abspath(fixInstance.xmlFileName)
     self.assertEqual(string, expectedString)
コード例 #22
0
ファイル: FixTest05.py プロジェクト: ajbstewart/wbd
 def test100_910_LatitudeShouldRaiseExceptionWithHAndDefaultAngle(self):
     expected = "0d0.0"
     aFix = Fix.Fix('testLogCA05.txt')
     aFix.setSightingFile('sightingFileCA05.xml')
     aFix.setStarFile("stars.txt")
     aFix.setAriesFile("aries.txt")
     aFix.getSightings("0d0.0", "0d0.0")
     actual = aFix.assumedLong
     self.assertEquals(expected, actual)
コード例 #23
0
ファイル: FixTest05.py プロジェクト: ajbstewart/wbd
 def test100_070_LongitudeShouldReturnDefault(self):
     expected = "0d0.0"
     aFix = Fix.Fix('testLogCA05.txt')
     aFix.setSightingFile('sightingFileCA05.xml')
     aFix.setStarFile("stars.txt")
     aFix.setAriesFile("aries.txt")
     aFix.getSightings("0d0.0", "0d0.0")
     actual = aFix.assumedLong
     self.assertEquals(expected, actual)
コード例 #24
0
ファイル: FixTest05.py プロジェクト: ajbstewart/wbd
 def test100_060_LongitudeShouldReturnValidString(self):
     expected = "85d33.4"
     aFix = Fix.Fix('testLogCA05.txt')
     aFix.setSightingFile('sightingFileCA05.xml')
     aFix.setStarFile("stars.txt")
     aFix.setAriesFile("aries.txt")
     aFix.getSightings("N27d59.5", "85d33.4")
     actual = aFix.assumedLong
     self.assertEquals(expected, actual)
コード例 #25
0
 def test500_020_ShouldWriteToTheLogFile(self):
     fixInstance=Fix.Fix("test3")
     fixInstance.setStarFile("stars.txt")
     logFileName=fixInstance.logFileName
     for line in reversed(open(logFileName).readlines()):
         string=line.rstrip()
         break
     expectedString="Star file:"+"\t"+os.path.abspath("stars.txt")
     self.assertEqual(string, expectedString)
コード例 #26
0
ファイル: FixTest03.py プロジェクト: WenyuZhu/wbd
 def test500_910_ShouldRaiseExceptionOnNotSettingAriesFile(self):
     expectedDiag = self.className + "getSightings:"
     theFix = F.Fix()
     theFix.setSightingFile('CA02_300_ValidOneStarWithDefaultValues.xml')
     with self.assertRaises(ValueError) as context:
         theFix.getSightings()
     self.assertEquals(expectedDiag,
                       context.exception.args[0][0:len(expectedDiag)])
     os.remove(self.DEFAULT_LOG_FILE)
コード例 #27
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.cleanup()   
コード例 #28
0
ファイル: FixTestCA05.py プロジェクト: lzz0019/wbd
 def test300_010_ShouldDefaultToZeroOnMissingParameter(self):
     theFix = F.Fix()
     theFix.setSightingFile("CA05_300_ValidSightingFile.xml")
     theFix.setStarFile("CA03_Valid_Stars.txt")
     theFix.setAriesFile("CA03_Valid_Aries.txt")
     theFix.getSightings()
     expectedResult = ("0d0.0", "0d0.0")
     result = theFix.getAssumedLatiLogi()
     self.assertTupleEqual(result, expectedResult)
コード例 #29
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")  
コード例 #30
0
ファイル: FixTest05.py プロジェクト: ajbstewart/wbd
 def test100_020_LatitudeShouldReturnValidStringWhereHIsS(self):
     expected = "S27d59.5"#hxdy.y
     aFix = Fix.Fix('testLogCA05.txt')
     aFix.setSightingFile('sightingFileCA05.xml')
     aFix.setStarFile("stars.txt")
     aFix.setAriesFile("aries.txt")
     aFix.getSightings("S27d59.5", "0d0.0")
     actual = aFix.assumedLat
     self.assertEquals(expected, actual)