def test300_101_Success_CalculationMissingDateAndTime(self): result = predict.predict({'op': 'predict', 'body': 'Betelgeuse'}) self.assert_('error' not in result) self.assertAlmostEqual(dispatch.degreeToDecimal(result['long']), dispatch.degreeToDecimal('11d41.6'), places=None, delta=1) self.assertEqual(result['lat'], '7d24.3')
def test300_113_Error_NoBody(self): result = predict.predict({ 'op': 'predict', 'date': '2016-01-17', 'time': '25:61:61' }) self.assert_('error' in result) self.assertEqual(result['error'], dispatch.ERROR_MANDATORY_INFO_MISSING)
def test300_112_Error_InvalidTime(self): result = predict.predict({ 'op': 'predict', 'body': 'Betelgeuse', 'date': '2016-01-17', 'time': '25:61:61' }) self.assert_('error' in result) self.assertEqual(result['error'], dispatch.ERROR_INVALID_TIME)
def test300_111_Error_InvalidDate(self): result = predict.predict({ 'op': 'predict', 'body': 'Betelgeuse', 'date': '13/13/9999', 'time': '03:15:42' }) self.assert_('error' in result) self.assertEqual(result['error'], dispatch.ERROR_INVALID_DATE)
def test300_110_Error_StarNotInCatalogue(self): result = predict.predict({ 'op': 'predict', 'body': 'asdf', 'date': '2016-01-17', 'time': '03:15:42' }) self.assert_('error' in result) self.assertEqual(result['error'], dispatch.ERROR_STAR_NOT_IN_CATALOGUE)
def test300_115_Error_ContainsLong(self): result = predict.predict({ 'op': 'predict', 'body': 'asdf', 'date': '2016-01-17', 'time': '03:15:42', 'long': '7d24.3' }) self.assert_('error' in result) self.assertEqual(result['error'], dispatch.ERROR_LAT_LON_INCLUDED)
def test300_100_Success_Calculation(self): result = predict.predict({ 'op': 'predict', 'body': 'Betelgeuse', 'date': '2016-01-17', 'time': '03:15:42' }) self.assert_('error' not in result) self.assertAlmostEqual(dispatch.degreeToDecimal(result['long']), dispatch.degreeToDecimal('75d53.6'), places=None, delta=1) self.assertEqual(result['lat'], '7d24.3')
def test1000_MandatoryInformationMissing(self): self.assertEquals(SM.predict({'op': 'predict'}), { 'error': 'mandatory information is missing', 'op': 'predict' })