예제 #1
0
    def test_vessel_added_error(self):
        response = response_factory(os.path.join(FIXTURE_PATH,
                                                 'imo-not-found.xml'),
                                    meta={'vessel': self.vessel})
        with patch(
                'kp_scrapers.spiders.ais.marinetraffic.MarineTrafficSpider.logger'
        ):
            spider = MarineTrafficSpider(fleet='True')

            spider.check_vessel_was_added(response)

            spider.logger.error.assert_called_once_with(
                "Could not add vessel {name} (IMO: {imo}, MMSI: {mmsi}): "
                "{message}".format(message="VESSEL IMO NOT FOUND IN DATABASE",
                                   **self.vessel))
예제 #2
0
    def test_vessel_successfully_added(self):
        response = response_factory(os.path.join(FIXTURE_PATH,
                                                 'vessel-added.xml'),
                                    meta={'vessel': self.vessel})
        with patch(
                'kp_scrapers.spiders.ais.marinetraffic.MarineTrafficSpider.logger'
        ) as logger:
            spider = MarineTrafficSpider(fleet='True')

            spider.check_vessel_was_added(response)

        self.assertEqual(logger.info.call_count, 1)
        self.assertEqual(
            logger.info.call_args_list[-1][0][0],
            "Vessel {name} (IMO: {imo}, MMSI: {mmsi}) added to MT"
            " fleet.".format(message="FLEET ITEM UPDATED", **self.vessel),
        )