Quellcode durchsuchen

[native] Remove any special handling of "id" field

jherve vor 1 Jahr
Ursprung
Commit
efaa7d1be0
2 geänderte Dateien mit 4 neuen und 7 gelöschten Zeilen
  1. 1 7
      native/src/job_search/job_storage.py
  2. 3 0
      native/tests/test_storage.py

+ 1 - 7
native/src/job_search/job_storage.py

@@ -51,7 +51,7 @@ def convert_to_bool(s: str) -> bool:
 
 @dataclass
 class JobOffer:
-    id: str = field(init=False)
+    id: str
     url: str = field(repr=False)
     title: str
     company: str
@@ -89,10 +89,6 @@ class JobOffer:
             self._alternate_url = convert_to_parse_result(self.alternate_url)
             self.alternate_url = self._alternate_url.geturl()
 
-        if self.origin == JobOfferOrigin.LINKED_IN:
-            path = Path(self._url.path)
-            self.id = f"linked_in_{path.name}"
-
     def to_storage(self):
         return {
             k: v
@@ -102,8 +98,6 @@ class JobOffer:
 
     @staticmethod
     def from_storage(dict: dict):
-        id = dict.pop("id")
-
         for field, converter in [
             ("origin", JobOfferOrigin),
             ("application_process", ApplicationProcess),

+ 3 - 0
native/tests/test_storage.py

@@ -19,6 +19,7 @@ def job_storage(request, tmp_path):
 @pytest.fixture(
     params=[
         JobOffer(
+            id="linked_in_3755217595",
             url="https://www.linkedin.com/jobs/view/3755217595",
             title="Job title",
             company="Company",
@@ -30,6 +31,7 @@ def job_storage(request, tmp_path):
             publication_date=date.today(),
         ),
         JobOffer(
+            id="linked_in_3755217595",
             url="https://www.linkedin.com/jobs/view/3755217595",
             title="Job title",
             company="Company",
@@ -52,6 +54,7 @@ def job_storage(request, tmp_path):
             application_rejection_date=date.today(),
         ),
         JobOffer(
+            id="linked_in_3755217595",
             url="https://www.linkedin.com/jobs/view/3755217595",
             title="Job title",
             company="Company",