How to use the greynoise.cli.main function in greynoise

To help you get started, we’ve selected a few greynoise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GreyNoise-Intelligence / pygreynoise / tests / cli / test_subcommand.py View on Github external
def test_empty_input_file(self, api_client):
        """Error is returned if empty input fle is passed."""
        runner = CliRunner()

        expected = (
            "Error: at least one query must be passed either as an argument "
            "(QUERY) or through the -i/--input_file option."
        )

        result = runner.invoke(
            subcommand.stats,
            ["-i", StringIO()],
            parent=Context(main, info_name="greynoise"),
        )
        assert result.exit_code == -1
        assert "Usage: greynoise stats" in result.output
        assert expected in result.output
        api_client.query.assert_not_called()
github GreyNoise-Intelligence / pygreynoise / tests / cli / test_init.py View on Github external
def test_logging_configured(self):
        """Logging is configured."""
        runner = CliRunner()

        with patch("greynoise.cli.structlog") as structlog, patch(
            "greynoise.cli.configure_logging"
        ) as configure_logging:
            structlog.is_configured.return_value = False
            query_command = Mock()
            with patch.dict(main.commands, query=query_command):
                runner.invoke(main, [""])

        configure_logging.assert_called_once_with()
github GreyNoise-Intelligence / pygreynoise / tests / cli / test_init.py View on Github external
def test_help(self, help_option):
        """Usage string is printed."""
        runner = CliRunner()
        result = runner.invoke(main, help_option)

        assert result.exit_code == 0
        assert "Usage:" in result.output