Exemple #1
0
    def test_get_vessel_fleet_with_callback(self):
        def callback(a, b):
            pass

        spider = MarineTrafficSpider(show_fleet='',
                                     getkey=self.api_key,
                                     fleet_name='FLEET')
        idx = -1
        for idx, item in enumerate(spider.get_vessel_fleet(cb=callback)):
            self.assertIn('/api/getfleet/{}'.format(self.api_key), item.url)
            self.assertIs(item.callback, callback)

        self.assertEqual(idx, 0)
Exemple #2
0
    def test_get_vessel_fleet(self):
        api_key = '123456'
        spider = MarineTrafficSpider(show_fleet='',
                                     getkey=api_key,
                                     fleet_name='FLEET',
                                     fleet_id='xyz')
        idx = -1
        for idx, item in enumerate(spider.get_vessel_fleet()):
            self.assertIn('/api/getfleet/{}/fleet_id:xyz'.format(self.api_key),
                          item.url)
            self.assertIs(item.callback, spider.show_fleet)

        self.assertEqual(idx, 0)