Skip to content

Commit

Permalink
style(charm): run the linter
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-hagemann committed Oct 3, 2023
1 parent bbf6675 commit 9f43d27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
19 changes: 9 additions & 10 deletions vm_operator/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
"""

import logging
import os
import secrets
import shutil
from os import environ
from pathlib import Path
from subprocess import CalledProcessError, check_output

import ops

from pathlib import Path
from git import Repo
import shutil
from charms.operator_libs_linux.v0 import apt, systemd
from charms.data_platform_libs.v0.data_interfaces import DatabaseCreatedEvent, DatabaseRequires
from ops.model import MaintenanceStatus, BlockedStatus, ActiveStatus
from ops.framework import StoredState
from subprocess import check_output, CalledProcessError
import os
from os import environ
from charms.operator_libs_linux.v0 import apt, systemd
from git import Repo
from jinja2 import Template
from ops.framework import StoredState
from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus

logger = logging.getLogger(__name__)

Expand Down
17 changes: 8 additions & 9 deletions vm_operator/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import os
import unittest

import logging
from pathlib import Path
from unittest import mock
from unittest.mock import Mock, call, mock_open, patch
from unittest.mock import call, mock_open, patch

from charm import APP_PATH, CARGO_PATH, UNIT_PATH, RatingsCharm
from charms.data_platform_libs.v0.data_interfaces import DatabaseCreatedEvent
from charm import RatingsCharm, UNIT_PATH, APP_PATH, CARGO_PATH
from charms.operator_libs_linux.v0 import apt, systemd
from charms.operator_libs_linux.v0 import apt
from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus, WaitingStatus
import os
from os import environ
from ops.testing import Harness


class MockDatabaseEvent:
def __init__(self, id, name="database"):
self.name = name
Expand Down Expand Up @@ -266,14 +265,14 @@ def test_ratings_jwt_secret_create(self):
@mock.patch("charms.operator_libs_linux.v0.systemd.service_restart")
@mock.patch("charm.check_output")
@mock.patch("charm.Repo")
def test_on_pull_and_rebuild(self, _MockRepo, _check, _restart):
def test_on_pull_and_rebuild(self, _mock_repo, _check, _restart):

# Can't mock chain in the @mock.patch, so set up chaining manually for pull
mock_pull = mock.Mock()
mock_origin = mock.Mock(pull=mock_pull)
mock_remotes = mock.Mock(origin=mock_origin)

_MockRepo.return_value.remotes = mock_remotes # Set up mock chaining
_mock_repo.return_value.remotes = mock_remotes # Set up mock chaining

# Create event mock
mock_event = mock.Mock()
Expand Down

0 comments on commit 9f43d27

Please sign in to comment.