class TestMetEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_met_endpoint(self): self.assertEqual(self.a.met({'icaoCode': 'SBBR'}).status_code, 200) def test_no_data_met_endpoint(self): self.assertEqual(self.a.met({}), None)
class TestAeroEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_aero_endpoint(self): self.assertEqual(self.a.aero({'icaoCode': 'SBBR'}).status_code, 200) # May fail in certain times because the system might be updating its data. # So there's nothing wrong with the code, it just returns a response.text # "em atualização (updating)". def test_aero_no_data_endpoint(self): self.assertEqual(self.a.aero({}).status_code, None)
class TestNotamEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_notam_endpoint(self): self.assertEqual( self.a.notam({ 'icaoCode': ['SBBR', 'SBGL'], 'dist': 'N' }).status_code, 200) def test_notam_no_data_endpoint(self): self.assertEqual(self.a.notam({}).status_code, 200)
class TestSupEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_sup_endpoint(self): self.assertEqual( self.a.suplementos({ 'icaoCode': 'SBBR', 'S': 'A' }).status_code, 200) def test_sup_no_data_endpoint(self): self.assertEqual(self.a.suplementos({}).status_code, 200)
class TestCartasEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_cartas_endpoint(self): self.assertEqual( self.a.cartas({ 'icaoCode': 'SBBR', 'tipo': 'ADC' }).status_code, 200) def test_cartas_no_data_endpoint(self): self.assertEqual(self.a.cartas({}).status_code, 200)
class TestSunEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_sun_no_date_endpoint(self): self.assertEqual(self.a.sol({'icaoCode': 'SBBR'}).status_code, 200) def test_sun_with_date_endpoint(self): self.assertEqual( self.a.sol({ 'icaoCode': 'SBBR', 'dt_i': '2018-03-26', 'dt_f': '2018-03-28' }).status_code, 200) def test_sun_no_data_endpoint(self): self.asserteEqual(self.a.sol().status_code, 200)
def _get_chart(icao: str, _type: str): try: items = json.loads(AISWEB(BOT_AIS_KEY, BOT_AIS_TOKEN).cartas({'IcaoCode': icao, 'tipo': _type}, method='GET', response_type='JSON'))['aisweb']['cartas'] if (items.get('@total') == '0'): return False, 'Error: no charts were found' items = [items['item']] if items.get('@total') == '1' else items.get('item') return True, items except Exception as e: if 'Error: method GET not supported at this time!' in str(e): return False, 'Error: connection error'
def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>')
class TestFixesEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_fixes_endpoint(self): self.assertEqual(self.a.fixos().status_code, 200)
def test_instance_without_keys(self): with self.assertRaises(TypeError): AISWEB()
def test_instance_numeric_args(self): with self.assertRaises(TypeError): AISWEB(123, 123)
def test_instance_repr_numeric_empty_arg(self): with self.assertRaises(TypeError): AISWEB(0, 0)
def test_instance_empty_args_dict(self): with self.assertRaises(TypeError): AISWEB({}, {})
def test_instance_empty_args_list(self): with self.assertRaises(TypeError): AISWEB([], [])
def test_instance_empty_args_string(self): with self.assertRaises(TypeError): AISWEB('', '')
class TestChecklistEndpoint(unittest.TestCase): def setUp(self): self.a = AISWEB('<API_KEY>', '<API_PASS>') def test_checklist_endpoint(self): self.assertEqual(self.a.checklist().status_code, 200)