Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jvasquezrojas committed Jul 1, 2024
1 parent a541990 commit 82efb0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions tests/api/commands/test_snow_typer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import uuid
from functools import partial
from unittest import mock
from unittest.mock import MagicMock
Expand All @@ -31,9 +31,9 @@ def class_factory(
):
class _CustomTyper(SnowTyper):
@staticmethod
def pre_execute():
def pre_execute(execution_id):
if pre_execute:
pre_execute()
pre_execute(execution_id)

@staticmethod
def post_execute():
Expand All @@ -46,9 +46,9 @@ def process_result(result):
result_handler(result)

@staticmethod
def exception_handler(err):
def exception_handler(err, execution_id):
if exception_handler:
exception_handler(err)
exception_handler(err, execution_id)

def create_instance(self):
return self
Expand Down Expand Up @@ -190,10 +190,12 @@ def test_enabled_command_is_not_visible(cli, snapshot):


@mock.patch("snowflake.cli.app.telemetry.log_command_usage")
def test_snow_typer_pre_execute_sends_telemetry(mock_log_command_usage, cli):
@mock.patch("uuid.uuid4")
def test_snow_typer_pre_execute_sends_telemetry(mock_uuid, mock_log_command_usage, cli):
mock_uuid.return_value = uuid.UUID("8a2225b3800c4017a4a9eab941db58fa")
result = cli(app_factory(SnowTyperFactory))(["simple_cmd", "Norma"])
assert result.exit_code == 0
mock_log_command_usage.assert_called_once_with()
mock_log_command_usage.assert_called_once_with("8a2225b3800c4017a4a9eab941db58fa")


@mock.patch("snowflake.cli.app.telemetry.flush_telemetry")
Expand Down
4 changes: 2 additions & 2 deletions tests/app/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_executing_command_sends_telemetry_data(
mock_time.return_value = "123"
mock_platform.return_value = "FancyOS"
mock_version.return_value = "2.3.4"
uuid.uuid4.return_value = uuid.UUID("8a2225b3800c4017a4a9eab941db58fa")
mock_uuid4.return_value = uuid.UUID("8a2225b3800c4017a4a9eab941db58fa")
result = runner.invoke(["connection", "test"], catch_exceptions=False)
assert result.exit_code == 0, result.output

Expand Down Expand Up @@ -89,7 +89,7 @@ def test_executing_command_sends_project_definition_in_telemetry_data(
def test_failing_executing_command_sends_telemetry_data(
_, mock_uuid4, mock_conn, project_directory, runner
):
uuid.uuid4.return_value = uuid.UUID("8a2225b3800c4017a4a9eab941db58fa")
mock_uuid4.return_value = uuid.UUID("8a2225b3800c4017a4a9eab941db58fa")
with project_directory("napp_post_deploy_missing_file"):
runner.invoke(["app", "run"], catch_exceptions=False)

Expand Down

0 comments on commit 82efb0c

Please sign in to comment.