Coverage for chalicelib/core/issue_tracking/base.py: 83%
40 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
1from abc import ABC, abstractmethod
3from chalicelib.utils import pg_client, helper
6class BaseIntegration(ABC):
8 def __init__(self, user_id, ISSUE_CLASS):
9 self._user_id = user_id
10 self._issue_handler = ISSUE_CLASS(self.integration_token)
12 @property
13 @abstractmethod
14 def provider(self):
15 pass
17 @property
18 @abstractmethod
19 def issue_handler(self):
20 pass
22 @property
23 def integration_token(self):
24 integration = self.get()
25 if integration is None:
26 print("no token configured yet")
27 return None
28 return integration["token"]
30 def get(self):
31 with pg_client.PostgresClient() as cur:
32 cur.execute(
33 cur.mogrify(
34 """SELECT *
35 FROM public.oauth_authentication
36 WHERE user_id=%(user_id)s AND provider=%(provider)s;""",
37 {"user_id": self._user_id, "provider": self.provider.lower()})
38 )
39 return helper.dict_to_camel_case(cur.fetchone())
41 @abstractmethod
42 def get_obfuscated(self):
43 pass
45 @abstractmethod
46 def update(self, changes, obfuscate=False):
47 pass
49 @abstractmethod
50 def _add(self, data):
51 pass
53 @abstractmethod
54 def delete(self):
55 pass
57 @abstractmethod
58 def add_edit(self, data):
59 pass