Exemplo n.º 1
0
    def test_no_crash_when_both_fleet_and_vessel_list_are_empty(self):
        with patch(VESSELS_MODULE, new=ForcedCollection()):
            spider = MarineTrafficSpider(
                fleet='True',
                fleet_name='MT',
                setkey='abcdef',
                getkey='123456',
                allow_removal='true',
            )
            response = response_factory(
                os.path.join(FIXTURE_PATH, 'fleet-empty.xml'))
            requests = []
            for request in spider.update_fleet(response):
                requests.append(request)

        self.assertEqual(len(requests), 0)
Exemplo n.º 2
0
    def test_vessel_removal_when_fleet_empty_vessel_list_contains_one_vessel_other_provider(
            self):
        self.vessel['providers'] = ['Other Provider']
        with patch(VESSELS_MODULE, new=ForcedCollection([self.vessel])):
            spider = MarineTrafficSpider(
                fleet='True',
                fleet_name='MT',
                setkey='abcdef',
                getkey='123456',
                allow_removal='true',
            )
            response = response_factory(
                os.path.join(FIXTURE_PATH, 'fleet-empty.xml'))
            requests = []
            for request in spider.update_fleet(response):
                requests.append(request)

        self.assertEqual(len(requests), 0)
Exemplo n.º 3
0
    def test_vessel_removal_when_fleet_contains_one_vessel_and_vessel_list_empty(
            self):
        with patch(VESSELS_MODULE, new=ForcedCollection()):
            spider = MarineTrafficSpider(fleet='True',
                                         fleet_name='MT',
                                         setkey='abcdef',
                                         getkey='123456',
                                         removal='true')
            response = response_factory(os.path.join(FIXTURE_PATH,
                                                     'fleet-one-vessel.xml'),
                                        klass=FakeXmlResponse)
            requests = []
            for request in spider.update_fleet(response):
                requests.append(request)

        self.assertEqual(len(requests), 1)
        request = requests[0]
        self.assertIn('action', request.meta)
        self.assertEqual(request.meta['action'], 'delete')
        self.assertIn('imo:{}'.format(self.vessel['imo']), request.url)
        self.assertNotIn('active:1', request.url)
        self.assertIn('delete:1', request.url)