def test400_090ShouldcalculateCorrectedDistanceandAzimuthwithProperData(self): values = {'assumedLat': '35d59.7', 'altitude': '37d17.4', 'assumedLong': '74d35.3', 'long': '154d5.4', 'lat': '89d20.1', 'op': 'correct'} expectedValues = {'assumedLat': '35d59.7', 'correctedDistance': '104', 'altitude': '37d17.4', 'assumedLong': '74d35.3', 'long': '154d5.4', 'correctedAzimuth': '0d36.8', 'lat': '89d20.1', 'op': 'correct'} self.assertDictEqual(DP.dispatch(values), expectedValues)
def test_dispatch_empty_input(self): #DT.dispatch({}) output = DT.dispatch({}) self.assertTrue(output == {'error': 'no op is specified'})
def test_dispatch_invalid_observation(self): output = DT.dispatch({'observation': '101d15.2', 'height': '6', 'pressure': '1010', 'horizon': 'natural', 'op': 'adjust', 'temperature': '71'}) self.assertTrue(output == {'temperature': '71', 'height': '6', 'pressure': '1010', 'horizon': 'natural', 'error': 'degrees are out of range, should be between 0 and 90', 'observation': '101d15.2', 'op': 'adjust'})
def test500_040_ShouldHandleInvalidOp(self): input = {'op': 'not a real op'} expected = {'op': 'not a real op', 'error': 'op is not a legal operation'} self.assertEqual(dispatch.dispatch(input), expected)
def test100_021_ShouldReturnParameterIsNotALegalOperation(self): expectedString = {'error': 'op is not a legal operation'} self.assertEquals(expectedString, DSP.dispatch({'op': 'unknown'}))
def test500_040_ShouldDispatchToPredict(self): test_input = {'op':'predict', 'body': 'Betelgeuse', 'date': '2016-01-17', 'time': '03:15:42'} expected = {'op':'predict', 'body': 'Betelgeuse', 'date': '2016-01-17', 'time': '03:15:42', 'long':'75d53.6', 'lat':'7d24.3'} actual = dispatch.dispatch(test_input) self.assertEqual(actual, expected)
def test500_020_ShouldHandleNonDictInput(self): expected = {'error': 'parameter is not a dictionary'} self.assertEqual(dispatch.dispatch(1), expected)
def test100_160ShouldGiveErrorForObservationWithoutD(self): dict = {} dict['op'] = 'adjust' dict['observation'] = '4530.0' self.assertEquals(dispatch.dispatch(dict)['error'], 'bad observation')
def test100_170ShouldGiveErrorForNonIntegerDegrees(self): dict = {} dict['op'] = 'adjust' dict['observation'] = 'xd30.0' self.assertEquals(dispatch.dispatch(dict)['error'], 'bad observation')
def test500_040ShouldReturnErrorONAlreadyCorrectedValuesINInputDict(self): values = {'op':'correct', 'lat':'16d32.3', 'long':'95d41.6', 'altitude':'13d42.3', 'assumedLat':'-53d38.4', 'assumedLong':' 74d35.3', 'correctedDistance':'3950', 'correctedAzimuth':'164d42.9'} self.assertTrue(DP.dispatch(values).has_key("error"), True)
def test100_150ShouldGiveErrorForMissingObservation(self): dict = {} dict['op'] = 'adjust' self.assertEquals( dispatch.dispatch(dict)['error'], 'no observation is specified')
def test500_030ShouldReturnErrorONWrongValueOfLat(self): values = {'op':'correct', 'lat':'-91d32.3','long':'95d41.6', 'altitude':'13d42.3', 'assumedLat':'-153d38.4', 'assumedLong':' 74d35.3'} self.assertTrue(DP.dispatch(values).has_key("error"), True)
def test400_070ShouldReturnErrorONMissingLat(self): values = {'op':'correct'} self.assertTrue(DP.dispatch(values).has_key("error"), True)
def test400_060ShouldReturnErrorONMissingaltitude(self): values = {'op':'correct', 'lat':'16d32.3', 'long':'95d41.6', 'assumedLat':'-53d38.4', 'assumedLong':' 74d35.3'} self.assertTrue(DP.dispatch(values).has_key("error"), True)
def test900_060_shouldReturnErrorParameterMissing(self): sighting = {'op': ''} result = dispatch.dispatch(sighting) expectedResult = {'error': 'op is not a legal operation', 'op': ''} self.assertDictEqual(result, expectedResult)
def test100_180ShouldGiveErrorForNonNumericMinutes(self): dict = {} dict['op'] = 'adjust' dict['observation'] = '45dy.y' self.assertEquals(dispatch.dispatch(dict)['error'], 'bad observation')
def test100_010_shouldReturnValuesOpPredict(self): sighting = {'op': 'predict'} result = dispatch.dispatch(sighting) expectedResult = {'op': 'predict'} self.assertDictEqual(result, expectedResult)
def test200_010ShouldCalculateBetelgeuseCaseAllDefault(self): dict = {} dict['op'] = 'predict' dict['body'] = 'Betelgeuse' self.assertEquals(dispatch.dispatch(dict)['long'], '11d41.7') self.assertEquals(dispatch.dispatch(dict)['lat'], '7d24.3')
def test500_010_ShouldHandleNoInput(self): expected = {'error': 'parameter is missing'} self.assertEqual(dispatch.dispatch(), expected)
def test100_010ShouldCalculateNominalCaseAllDefault(self): dict = {} dict['op'] = 'adjust' dict['observation'] = '42d0.0' self.assertEquals(dispatch.dispatch(dict)['altitude'], '41d59.0')
def test500_030_ShouldHandleNoOp(self): expected = {'error': 'no op is specified'} self.assertEqual(dispatch.dispatch({}), expected)
def test100_020ShouldCalculateNominalCaseNominalHeightRestDefault(self): dict = {} dict['op'] = 'adjust' dict['observation'] = '45d30.0' dict['height'] = '10' self.assertEquals(dispatch.dispatch(dict)['altitude'], '45d26.0')
def test100_020_ShouldReturnParameterIsNotADictionary(self): expectedString = {'error': 'parameter is not a dictionary'} self.assertEquals(expectedString, DSP.dispatch(42))
def test900_020_shouldReturnErrorParameterMissing(self): result = dispatch.dispatch() expectedResult = {'error': 'parameter is missing'} self.assertDictEqual(result, expectedResult)
def test200_010_ShouldReturnMandatoryInfoIsMissing(self): expectedString = {'error': 'mandatory information is missing'} self.assertEquals(expectedString, DSP.dispatch({'op': 'adjust'}))
def test900_030_shouldReturnErrorNotDict(self): sighting = 42 result = dispatch.dispatch(sighting) expectedResult = {'error': 'parameter is not a dictionary'} self.assertDictEqual(result, expectedResult)
def test_dispatch_invalid_dict(self): output = DT.dispatch(42) self.assertTrue(output == {'error':'parameter is not a dictionary'})
def test900_040_shouldReturnErrorNoOp(self): sighting = {'height': '100'} result = dispatch.dispatch(sighting) expectedResult = {'error': 'no op is specified', 'height': '100'} self.assertDictEqual(result, expectedResult)
def test200_01_ShouldReturnCorrectLatAndLong(self): input = {'op': 'predict', 'body': 'Betelgeuse', 'date': '2016-01-17', 'time': '03:15:42'} output = {'op':'predict', 'body': 'Betelgeuse', 'date': '2016-01-17', 'time': '03:15:42', 'long': '75d53.6','lat': '7d24.3'} self.assertDictEqual(DT.dispatch(input), output)
def test400_010ShouldcalculateCorrectedDistanceandAzimuthwithProperData(self): values = {'op':'correct', 'lat':'16d32.3', 'long':'95d41.6', 'altitude':'13d42.3', 'assumedLat':'-53d38.4', 'assumedLong':' 74d35.3'} expectedValues = {'op':'correct', 'lat':'16d32.3', 'long':'95d41.6', 'altitude':'13d42.3', 'assumedLat':'-53d38.4', 'assumedLong':' 74d35.3', 'correctedDistance':'3950', 'correctedAzimuth':'164d42.9'} self.assertDictEqual(DP.dispatch(values), expectedValues)