diff --git a/hub/models.py b/hub/models.py index 274dea0ca..74d1de972 100644 --- a/hub/models.py +++ b/hub/models.py @@ -1147,7 +1147,8 @@ def get_deduplication_hash(self) -> str: hash_values = ["name"] else: hash_values = [ - str(getattr(self, field)) for field in self.get_deduplication_field_names() + str(getattr(self, field)) + for field in self.get_deduplication_field_names() ] return hashlib.md5("".join(hash_values).encode()).hexdigest() @@ -2582,6 +2583,7 @@ class LocalJSONSource(ExternalDataSource): """ A test table. """ + crm_type = "test" has_webhooks = False automated_webhooks = False @@ -2599,7 +2601,7 @@ def get_deduplication_field_names(self) -> list[str]: def healthcheck(self): return True - + @cached_property def df(self): return pd.DataFrame(self.data).set_index(self.id_field) @@ -2607,10 +2609,8 @@ def df(self): def field_definitions(self): # get all keys from self.data return [ - self.FieldDefinition( - label=col, - value=col - ) for col in self.df.columns.tolist() + self.FieldDefinition(label=col, value=col) + for col in self.df.columns.tolist() ] def get_record_id(self, record: dict): @@ -2645,7 +2645,9 @@ async def update_many(self, mapped_records, **kwargs): await self.update_one(mapped_record) def delete_one(self, record_id): - self.data = [record for record in self.data if record[self.id_field] != record_id] + self.data = [ + record for record in self.data if record[self.id_field] != record_id + ] self.save() def create_one(self, record): @@ -2658,6 +2660,7 @@ def create_many(self, records): self.save() return records + class AirtableSource(ExternalDataSource): """ An Airtable table. diff --git a/hub/tests/test_source_parser.py b/hub/tests/test_source_parser.py index e1b4317fa..8df65d860 100644 --- a/hub/tests/test_source_parser.py +++ b/hub/tests/test_source_parser.py @@ -31,8 +31,8 @@ async def test_save_phone_field(self): data=[ {"id": "bad1", "phone": "123456789"}, {"id": "good1", "phone": "07123456789"}, - {"id": "good2", "phone": "+447123456789"} - ] + {"id": "good2", "phone": "+447123456789"}, + ], ) await sync_to_async(source.save)() @@ -57,4 +57,4 @@ async def test_save_phone_field(self): def test_valid_phone_number_for_usa(self): phone = "4155552671" result = validate_and_format_phone_number(phone, ["US"]) - self.assertEqual(result, "+14155552671") \ No newline at end of file + self.assertEqual(result, "+14155552671")