Skip to content

Commit

Permalink
chore(): Merge conflicts and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
merkata committed Oct 2, 2024
2 parents 79cfe80 + 3ea9512 commit 4a21c4c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src-docs/irc.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Configure the service.

---

<a href="../src/irc.py#L211"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/irc.py#L212"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `get_registration`

Expand Down Expand Up @@ -111,7 +111,7 @@ Simple flow:

---

<a href="../src/irc.py#L220"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/irc.py#L221"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `reload`

Expand All @@ -131,7 +131,7 @@ Check if the service is running and reload it.

---

<a href="../src/irc.py#L235"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/irc.py#L236"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `start`

Expand All @@ -149,7 +149,7 @@ Start the matrix-appservice-irc service.

---

<a href="../src/irc.py#L248"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/irc.py#L249"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `stop`

Expand Down
52 changes: 32 additions & 20 deletions tests/integration/any_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,73 @@
"""This code should be loaded into any-charm which is used for integration tests."""

import logging
import uuid

import ops
from any_charm_base import AnyCharmBase
from matrix_auth import MatrixAuthProviderData, MatrixAuthProvides

logger = logging.getLogger(__name__)


class AnyCharm(AnyCharmBase):
"""Execute a simple charm to test the relation."""

def __init__(self, *args, **kwargs):
"""Initialize the charm and observe the relation events.
Args:
args: Arguments to pass to the parent class.
kwargs: Keyword arguments to pass to the parent class
"""
super().__init__(*args, **kwargs)

self.plugin_auth = MatrixAuthProvides(self, relation_name="provide-irc-bridge")
self.framework.observe(self.on.provide_irc_bridge_relation_created, self._on_relation_created)
self.framework.observe(self.plugin_auth.on.matrix_auth_request_received, self._on_matrix_auth_request_received)
#self.framework.observe(self.on.provide_irc_bridge_relation_changed, self._on_relation_changed)
self.framework.observe(
self.on.provide_irc_bridge_relation_created, self._on_relation_created
)
self.framework.observe(
self.plugin_auth.on.matrix_auth_request_received, self._on_matrix_auth_request_received
)
# self.framework.observe(
# self.on.provide_irc_bridge_relation_changed, self._on_relation_changed)

def _on_relation_created(self, _):
"""Create the relation and set the relation data."""
relation = self.model.get_relation("provide-irc-bridge")
if relation is not None:
logger.info(f"Setting relation data")
logger.info("Setting relation data")
matrix_auth_data = MatrixAuthProviderData(
homeserver="https://example.com",
shared_secret="foobar"
homeserver="https://example.com", shared_secret="foobar"
)
matrix_auth_data.set_shared_secret_id(model=self.model, relation=relation)
self.plugin_auth.update_relation_data(relation, matrix_auth_data)

def _on_matrix_auth_request_received(self, _):
"""Get the relation data and log it."""
relation = self.model.get_relation("provide-irc-bridge")
if relation is not None:
logger.info(f"Getting relation data")
logger.info("Getting relation data")
remote_data = self.plugin_auth.get_remote_relation_data()
logger.info(f"Remote data: {remote_data}")
logger.info("Remote data: %s", remote_data)

def _on_relation_changed(self, _):
"""Get the relation data and log it."""
relation = self.model.get_relation("provide-irc-bridge")
logger.info(f"Relation: {relation}")
return
logger.info("Relation: %s", relation)
relation = self.model.get_relation("provide-irc-bridge")
logger.info(f"Relation: {relation}")
logger.info("Relation: %s", relation)
if relation is not None:
try:
logger.info(f"Getting relation data")
matrix_auth_data = MatrixAuthProviderData.from_relation(model=self.model, relation=relation)
logger.info("Getting relation data")
matrix_auth_data = MatrixAuthProviderData.from_relation(
model=self.model, relation=relation
)
except Exception as e:
logger.error(f"Failed to get relation data: {e}")
logger.info(f"Setting relation data")
logger.error("Failed to get relation data: %s", e)
logger.info("Setting relation data")
matrix_auth_data = MatrixAuthProviderData(
homeserver="https://example.com",
shared_secret="foobar"
homeserver="https://example.com", shared_secret="foobar"
)
matrix_auth_data.set_shared_secret_id(model=self.model, relation=relation)
self.plugin_auth.update_relation_data(relation, matrix_auth_data)
remote_data = self.plugin_auth.get_remote_relation_data()
logger.info(f"Remote data: {remote_data}")
logger.info("Remote data: %s", remote_data)

0 comments on commit 4a21c4c

Please sign in to comment.