Created
July 12, 2019 15:26
-
-
Save mplovepop/25b18ca75f7cc6b51b8ff219011b3fba to your computer and use it in GitHub Desktop.
Click testing with patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click.testing | |
import os | |
import snowtool.cli | |
import unittest | |
from unittest import mock | |
from ..mocks import MOCK_ENV, MOCK_SNOWFLAKE_VERSION, MockSnowflakeServer | |
@mock.patch.dict(os.environ, MOCK_ENV) | |
@mock.patch("snowflake.connector.connect") | |
class CliTest(unittest.TestCase): | |
def setUp(self): | |
self.runner = click.testing.CliRunner() | |
def test_version_command(self, connect): | |
connect.return_value = MockSnowflakeServer() | |
result = self.runner.invoke(snowtool.cli.main, ["version"]) | |
self.assertEqual(result.exit_code, 0) | |
self.assertEqual( | |
result.output, "Snowflake Version: {}\n".format(MOCK_SNOWFLAKE_VERSION) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment