コード例 #1
0
 def test200_920_ShouldRaiseErrorOnBadFileContents(self):
     expectedString = "StarCatalog.loadCatalog:"
     theCat = SC.StarCatalog()
     with self.assertRaises(ValueError) as context:
         theCat.loadCatalog("saoBad.txt", 6.0)
     self.assertEquals(
         expectedString, context.exception.args[0][0:len(expectedString)],
         "Major:  failure to check for file that doesn't fit star format")
コード例 #2
0
 def test200_935_ShouldRaiseErrorOnAboveRangeMagnitude(self):
     expectedString = "StarCatalog.loadCatalog:"
     theCat = SC.StarCatalog()
     with self.assertRaises(ValueError) as context:
         theCat.loadCatalog("saoLocal.txt", 30.1)
     self.assertEquals(
         expectedString, context.exception.args[0][0:len(expectedString)],
         "Minor:  failure to check for out-of-range magnitude")
コード例 #3
0
 def test200_925_ShouldRaiseErrorOnBadNonNumericMagnitude(self):
     expectedString = "StarCatalog.loadCatalog:"
     theCat = SC.StarCatalog()
     with self.assertRaises(ValueError) as context:
         theCat.loadCatalog("saoLocal.txt", "abc")
     self.assertEquals(expectedString,
                       context.exception.args[0][0:len(expectedString)],
                       "Major:  failure to check for nonNumeric magnitude")
コード例 #4
0
 def test200_910_ShouldRaiseErrorOnNonStringFileName(self):
     expectedString = "StarCatalog.loadCatalog:"
     theCat = SC.StarCatalog()
     with self.assertRaises(ValueError) as context:
         theCat.loadCatalog(42, 6.0)
     self.assertEquals(expectedString,
                       context.exception.args[0][0:len(expectedString)],
                       "Major:  failure to check for nonString file name")
コード例 #5
0
 def test500_915_ShouldRaiseExceptionOnEmptyCatalog(self):
     expectedString = "StarCatalog.getStarData:"
     theCat = SC.StarCatalog()
     with self.assertRaises(ValueError) as context:
         theCat.getStarData(starId=0)
     self.assertEquals(
         expectedString, context.exception.args[0][0:len(expectedString)],
         "Major:  failure to check for invalid degradation value")
コード例 #6
0
 def test500_930_ShouldRaiseErrorOnMissingStarId(self):
     expectedString = "StarCatalog.getStarData:"
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 2.0)
     with self.assertRaises(ValueError) as context:
         theCat.getStarData()
     self.assertEquals(
         expectedString, context.exception.args[0][0:len(expectedString)],
         "Major:  failure to check for invalid degradation value")
コード例 #7
0
 def test400_920_ShouldRaiseErrorOnNonNumericBrightestParm(self):
     expectedString = "StarCatalog.getStarCount:"
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 2.0)
     with self.assertRaises(ValueError) as context:
         theCat.getStarCount(dimmest=0.0, brightest="abc")
     self.assertEquals(
         expectedString, context.exception.args[0][0:len(expectedString)],
         "Major:  failure to check for invalid degradation value")
コード例 #8
0
 def test200_955_ShouldRaiseErrorOnDuplicateStarInSameFile(self):
     expectedString = "StarCatalog.loadCatalog:"
     theCat = SC.StarCatalog()
     with self.assertRaises(ValueError) as context:
         theCat.loadCatalog("saoLocalWithDuplicates.txt", 2.0)
     self.assertEquals(
         expectedString, context.exception.args[0][0:len(expectedString)],
         "Major:  failure to check for invalid degradation value")
     self.assertEquals(0, theCat.getStarCount())
コード例 #9
0
 def test200_915_ShouldRaiseErrorOnMissingFile(self):
     expectedString = "StarCatalog.loadCatalog:"
     theCat = SC.StarCatalog()
     randomFileName = ''.join(random.choice('abcd01234')
                              for x in range(8)) + "txt"
     with self.assertRaises(ValueError) as context:
         theCat.loadCatalog(randomFileName, 6.0)
     self.assertEquals(expectedString,
                       context.exception.args[0][0:len(expectedString)],
                       "Major:  failure to check for missing file")
コード例 #10
0
 def test500_010_ShouldGetStarDataIgnoreLeadingTrailingBlanks(self):
     id = ' 15384 '
     mag = 2.0
     ra = 165.932
     dec = 61.75089
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 3.0)
     retrievedStar = theCat.getStarData(id)
     self.assertEquals(id.strip(), retrievedStar[0])
     self.assertEquals(mag, retrievedStar[1])
     self.assertAlmostEquals(ra, retrievedStar[2], 3)
     self.assertAlmostEquals(dec, retrievedStar[3], 3)
コード例 #11
0
 def test_300_001_getStarCountWithMagnitudeLessThan5(self):
     stars = StarCatalog.StarCatalog()
     starCount = stars.loadCatalog(
         starFile="/home/softwareprocess/Desktop/sao.txt")
     starsLE5 = stars.getStarCount(brightest=5)
     print starsLE5
コード例 #12
0
 def test200_020_ShouldAddStarsFromMultipleCatalogs(self):
     theCat = SC.StarCatalog()
     self.assertEquals(51, theCat.loadCatalog("saoLocal.txt"))
     self.assertEquals(2, theCat.loadCatalog("saoLocal2.txt"))
     self.assertEquals(53, theCat.getStarCount())
コード例 #13
0
 def test200_020_ShouldLoadCatalogIfMagIsMissing(self):
     theCat = SC.StarCatalog()
     self.assertEquals(51, theCat.loadCatalog("saoLocal.txt"))
コード例 #14
0
 def test400_070_ShouldGetCountOfFreshCatalog(self):
     theCat = SC.StarCatalog()
     self.assertEquals(0.0,
                       theCat.getStarCount(dimmest=20.0, brightest=-20.0))
コード例 #15
0
 def test_300_900_getStarCountWithInValidMagnitude(self):
     stars = StarCatalog.StarCatalog()
     starCount = stars.loadCatalog(
         starFile="/home/softwareprocess/Desktop/sao.txt")
     self.assertRaises(stars.getStarCount('a', 5), ValueError)
コード例 #16
0
 def test400_050_ShouldReturnZeroIfDimmerIsBrigherThanBrightest(self):
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 3.0)
     self.assertEquals(0, theCat.getStarCount(dimmest=1.0, brightest=2.0))
コード例 #17
0
 def test400_060_ShouldGetCountOfEmptyCatalog(self):
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 3.0)
     theCat.emptyCatalog()
     self.assertEquals(0.0,
                       theCat.getStarCount(dimmest=20.0, brightest=-20.0))
コード例 #18
0
 def test100_010_ShouldConstruct(self):
     self.assertIsInstance(SC.StarCatalog(), SC.StarCatalog)
コード例 #19
0
 def test_300_003_getStarCountWithAllStars(self):
     stars = StarCatalog.StarCatalog()
     starCount = stars.loadCatalog(
         starFile="/home/softwareprocess/Desktop/sao.txt")
     allStars = stars.getStarCount()
     print allStars
コード例 #20
0
 def test400_030_ShouldGetCountOfStarsDimmerThanMag(self):
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 3.0)
     self.assertEquals(20, theCat.getStarCount(dimmest=1.0))
コード例 #21
0
 def test400_020_ShouldGetCountOfStarsBetweenBounds(self):
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 3.0)
     self.assertEquals(8, theCat.getStarCount(dimmest=2.0, brightest=2.0))
コード例 #22
0
 def test400_010_ShouldGetCountOfAllStars(self):
     theCat = SC.StarCatalog()
     starCount = theCat.loadCatalog("saoLocal.txt", 3.0)
     self.assertEquals(starCount, theCat.getStarCount())
コード例 #23
0
 def test300_020_ShouldEmptyAnCatalog(self):
     theCat = SC.StarCatalog()
     self.assertEquals(0, theCat.emptyCatalog())
コード例 #24
0
 def test300_010_ShouldEmptyTheCatalog(self):
     theCat = SC.StarCatalog()
     starCount = theCat.loadCatalog("saoLocal.txt", 3.0)
     self.assertEquals(starCount, theCat.emptyCatalog())
コード例 #25
0
 def test_200_900_loadStarsFromInValidFile(self):
     stars = StarCatalog.StarCatalog()
     self.assertRaises(
         stars.loadCatalog(
             starFile="/home/softwareprocess/Desktop/test.txt"), ValueError)
コード例 #26
0
 def test_300_002_getStarCountWithMagnitudeGreaterThan3(self):
     stars = StarCatalog.StarCatalog()
     starCount = stars.loadCatalog(
         starFile="/home/softwareprocess/Desktop/sao.txt")
     starsGE3 = stars.getStarCount(dimmest=3)
     print starsGE3
コード例 #27
0
 def test400_040_ShouldGetCountOfStarsBrighterThanMag(self):
     theCat = SC.StarCatalog()
     theCat.loadCatalog("saoLocal.txt", 3.0)
     self.assertEquals(41, theCat.getStarCount(brightest=0.0))
コード例 #28
0
 def test_300_000_getStarCountBetween2and5(self):
     stars = StarCatalog.StarCatalog()
     starCount = stars.loadCatalog(
         starFile="/home/softwareprocess/Desktop/sao.txt")
     starsBetween2And5 = stars.getStarCount(dimmest=5, brightest=2)
     print starsBetween2And5
コード例 #29
0
 def test200_010_ShouldLoadCatalog(self):
     theCat = SC.StarCatalog()
     self.assertEquals(20, theCat.loadCatalog("saoLocal.txt", 1))
コード例 #30
0
 def test_200_000_loadStarsFromValidFile(self):
     stars = StarCatalog.StarCatalog()
     starCount = stars.loadCatalog(
         starFile="/home/softwareprocess/Desktop/sao.txt")
     print starCount