Exemplo n.º 1
0
    def test_call_anitya_map(self, mock_method, message):
        """ Assert that `__call__` calls correct method based on message topic. """
        exp_message = ProjectMapCreated(topic=message.topic, body=message.body)

        self.consumer.__call__(message)

        mock_method.assert_called_with(exp_message)
Exemplo n.º 2
0
    def test_handle_anitya_map_new_no_fedora_mapping(self, mock_log, message):
        """
        Assert that message is correctly handled, when new mapping is added for other
        distribution than Fedora.
        """
        new_map_message = ProjectMapCreated(topic=message.topic,
                                            body=message.body)
        self.consumer.handle_anitya_map_new(new_map_message)

        self.assertIn(
            "New mapping on Arch, not for Fedora. Dropping",
            mock_log.info.call_args_list[0][0][0],
        )
Exemplo n.º 3
0
    def test_handle_anitya_map_new_version(self, mock_handle_update, mock_log,
                                           message):
        """
        Assert that message is correctly handled, when new mapping is added.
        """
        new_map_message = ProjectMapCreated(topic=message.topic,
                                            body=message.body)
        self.consumer.handle_anitya_map_new(new_map_message)

        self.assertIn(
            "Newly mapped 'pg-semver' to 'pg-semver' bears version '0.17.0'",
            mock_log.info.call_args_list[0][0][0],
        )

        mock_handle_update.assert_called_with("0.17.0", "pg-semver",
                                              new_map_message)
Exemplo n.º 4
0
    def test_handle_anitya_map_new_no_version(self, mock_anitya, mock_log,
                                              message):
        """
        Assert that message is correctly handled, when new mapping is added without
        version.
        """
        new_map_message = ProjectMapCreated(topic=message.topic,
                                            body=message.body)
        self.consumer.handle_anitya_map_new(new_map_message)

        self.assertIn(
            "Newly mapped 'gdtools' to 'R-gdtools' bears version None",
            mock_log.info.call_args_list[0][0][0],
        )

        self.assertIn("Forcing an anitya upstream check.",
                      mock_log.info.call_args_list[1][0][0])

        mock_anitya.assert_called_once_with("https://release-monitoring.org")
Exemplo n.º 5
0
    def __call__(self, msg):
        """
        Called when a message is received from queue.

        Params:
            msg (fedora_messaging.message.Message) The message we received
                from the queue.
        """
        topic, body, msg_id = msg.topic, msg.body, msg.id
        _log.debug("Received %r" % msg_id)

        if topic.endswith("anitya.project.version.update"):
            message = ProjectVersionUpdated(topic=msg.topic, body=msg.body)
            self.handle_anitya_version_update(message)
        elif topic.endswith("anitya.project.map.new"):
            message = ProjectMapCreated(topic=msg.topic, body=msg.body)
            self.handle_anitya_map_new(message)
        elif topic.endswith("buildsys.task.state.change"):
            self.handle_buildsys_scratch(msg)
        else:
            _log.debug("Dropping %r %r" % (topic, body))
            pass