Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

refactor(blocks): build each Apollo block test fixture once (#15825)

Reinier van der Leer31444f1268fb
diff --git a/autogpt_platform/backend/backend/blocks/apollo/organization.py b/autogpt_platform/backend/backend/blocks/apollo/organization.py
index f5e2e9b048..e55cd15dfd 100644
--- a/autogpt_platform/backend/backend/blocks/apollo/organization.py
+++ b/autogpt_platform/backend/backend/blocks/apollo/organization.py
@@ -101,109 +101,17 @@ To find IDs, identify the values for organization_id when you call this endpoint
test_output=[
(
"organization",
- Organization(
- id="1",
- name="Google",
- website_url="https://google.com",
- blog_url="https://google.com/blog",
- angellist_url="https://angel.co/google",
- linkedin_url="https://linkedin.com/company/google",
- twitter_url="https://twitter.com/google",
- facebook_url="https://facebook.com/google",
- primary_phone=PrimaryPhone(
- source="google",
- number="1234567890",
- sanitized_number="1234567890",
- ),
- languages=["en"],
- alexa_ranking=1000,
- phone="1234567890",
- linkedin_uid="1234567890",
- founded_year=2000,
- publicly_traded_symbol="GOOGL",
- publicly_traded_exchange="NASDAQ",
- logo_url="https://google.com/logo.png",
- chrunchbase_url="https://chrunchbase.com/google",
- primary_domain="google.com",
- sanitized_phone="1234567890",
- owned_by_organization_id="1",
- intent_strength="strong",
- show_intent=True,
- has_intent_signal_account=True,
- intent_signal_account="1",
- ),
+ _sample_organization(),
),
(
"organizations",
[
- Organization(
- id="1",
- name="Google",
- website_url="https://google.com",
- blog_url="https://google.com/blog",
- angellist_url="https://angel.co/google",
- linkedin_url="https://linkedin.com/company/google",
- twitter_url="https://twitter.com/google",
- facebook_url="https://facebook.com/google",
- primary_phone=PrimaryPhone(
- source="google",
- number="1234567890",
- sanitized_number="1234567890",
- ),
- languages=["en"],
- alexa_ranking=1000,
- phone="1234567890",
- linkedin_uid="1234567890",
- founded_year=2000,
- publicly_traded_symbol="GOOGL",
- publicly_traded_exchange="NASDAQ",
- logo_url="https://google.com/logo.png",
- chrunchbase_url="https://chrunchbase.com/google",
- primary_domain="google.com",
- sanitized_phone="1234567890",
- owned_by_organization_id="1",
- intent_strength="strong",
- show_intent=True,
- has_intent_signal_account=True,
- intent_signal_account="1",
- ),
+ _sample_organization(),
],
),
],
test_mock={
- "search_organizations": lambda *args, **kwargs: [
- Organization(
- id="1",
- name="Google",
- website_url="https://google.com",
- blog_url="https://google.com/blog",
- angellist_url="https://angel.co/google",
- linkedin_url="https://linkedin.com/company/google",
- twitter_url="https://twitter.com/google",
- facebook_url="https://facebook.com/google",
- primary_phone=PrimaryPhone(
- source="google",
- number="1234567890",
- sanitized_number="1234567890",
- ),
- languages=["en"],
- alexa_ranking=1000,
- phone="1234567890",
- linkedin_uid="1234567890",
- founded_year=2000,
- publicly_traded_symbol="GOOGL",
- publicly_traded_exchange="NASDAQ",
- logo_url="https://google.com/logo.png",
- chrunchbase_url="https://chrunchbase.com/google",
- primary_domain="google.com",
- sanitized_phone="1234567890",
- owned_by_organization_id="1",
- intent_strength="strong",
- show_intent=True,
- has_intent_signal_account=True,
- intent_signal_account="1",
- )
- ]
+ "search_organizations": lambda *args, **kwargs: [_sample_organization()]
},
effect=BlockEffect.READ,
)
@@ -228,3 +136,37 @@ To find IDs, identify the values for organization_id when you call this endpoint
for organization in organizations:
yield "organization", organization
yield "organizations", organizations
+
+
+def _sample_organization() -> Organization:
+ return Organization(
+ id="1",
+ name="Google",
+ website_url="https://google.com",
+ blog_url="https://google.com/blog",
+ angellist_url="https://angel.co/google",
+ linkedin_url="https://linkedin.com/company/google",
+ twitter_url="https://twitter.com/google",
+ facebook_url="https://facebook.com/google",
+ primary_phone=PrimaryPhone(
+ source="google",
+ number="1234567890",
+ sanitized_number="1234567890",
+ ),
+ languages=["en"],
+ alexa_ranking=1000,
+ phone="1234567890",
+ linkedin_uid="1234567890",
+ founded_year=2000,
+ publicly_traded_symbol="GOOGL",
+ publicly_traded_exchange="NASDAQ",
+ logo_url="https://google.com/logo.png",
+ chrunchbase_url="https://chrunchbase.com/google",
+ primary_domain="google.com",
+ sanitized_phone="1234567890",
+ owned_by_organization_id="1",
+ intent_strength="strong",
+ show_intent=True,
+ has_intent_signal_account=True,
+ intent_signal_account="1",
+ )
diff --git a/autogpt_platform/backend/backend/blocks/apollo/people.py b/autogpt_platform/backend/backend/blocks/apollo/people.py
index 28bb4e4255..2f67c19bcf 100644
--- a/autogpt_platform/backend/backend/blocks/apollo/people.py
+++ b/autogpt_platform/backend/backend/blocks/apollo/people.py
@@ -139,166 +139,13 @@ class SearchPeopleBlock(Block):
(
"people",
[
- Contact(
- contact_roles=[],
- id="1",
- name="John Doe",
- first_name="John",
- last_name="Doe",
- linkedin_url="https://www.linkedin.com/in/johndoe",
- title="Software Engineer",
- organization_name="Google",
- organization_id="123456",
- contact_stage_id="1",
- owner_id="1",
- creator_id="1",
- person_id="1",
- email_needs_tickling=True,
- source="apollo",
- original_source="apollo",
- headline="Software Engineer",
- photo_url="https://www.linkedin.com/in/johndoe",
- present_raw_address="123 Main St, Anytown, USA",
- linkededin_uid="123456",
- extrapolated_email_confidence=0.8,
- salesforce_id="123456",
- salesforce_lead_id="123456",
- salesforce_contact_id="123456",
- saleforce_account_id="123456",
- crm_owner_id="123456",
- created_at="2021-01-01",
- emailer_campaign_ids=[],
- direct_dial_status="active",
- direct_dial_enrichment_failed_at="2021-01-01",
- email_status="active",
- email_source="apollo",
- account_id="123456",
- last_activity_date="2021-01-01",
- hubspot_vid="123456",
- hubspot_company_id="123456",
- crm_id="123456",
- sanitized_phone="123456",
- merged_crm_ids="123456",
- updated_at="2021-01-01",
- queued_for_crm_push=True,
- suggested_from_rule_engine_config_id="123456",
- email_unsubscribed=None,
- label_ids=[],
- has_pending_email_arcgate_request=True,
- has_email_arcgate_request=True,
- existence_level=None,
- email=None,
- email_from_customer=None,
- typed_custom_fields=[],
- custom_field_errors=None,
- salesforce_record_id=None,
- crm_record_url=None,
- email_status_unavailable_reason=None,
- email_true_status=None,
- updated_email_true_status=True,
- contact_rule_config_statuses=[],
- source_display_name=None,
- twitter_url=None,
- contact_campaign_statuses=[],
- state=None,
- city=None,
- country=None,
- account=None,
- contact_emails=[],
- organization=None,
- employment_history=[],
- time_zone=None,
- intent_strength=None,
- show_intent=True,
- phone_numbers=[],
- account_phone_note=None,
- free_domain=True,
- is_likely_to_engage=True,
- email_domain_catchall=True,
- contact_job_change_event=None,
- ),
+ _sample_contact(),
],
),
],
test_mock={
"search_people": lambda query, credentials: [
- Contact(
- id="1",
- name="John Doe",
- first_name="John",
- last_name="Doe",
- linkedin_url="https://www.linkedin.com/in/johndoe",
- title="Software Engineer",
- organization_name="Google",
- organization_id="123456",
- contact_stage_id="1",
- owner_id="1",
- creator_id="1",
- person_id="1",
- email_needs_tickling=True,
- source="apollo",
- original_source="apollo",
- headline="Software Engineer",
- photo_url="https://www.linkedin.com/in/johndoe",
- present_raw_address="123 Main St, Anytown, USA",
- linkededin_uid="123456",
- extrapolated_email_confidence=0.8,
- salesforce_id="123456",
- salesforce_lead_id="123456",
- salesforce_contact_id="123456",
- saleforce_account_id="123456",
- crm_owner_id="123456",
- created_at="2021-01-01",
- emailer_campaign_ids=[],
- direct_dial_status="active",
- direct_dial_enrichment_failed_at="2021-01-01",
- email_status="active",
- email_source="apollo",
- account_id="123456",
- last_activity_date="2021-01-01",
- hubspot_vid="123456",
- hubspot_company_id="123456",
- crm_id="123456",
- sanitized_phone="123456",
- merged_crm_ids="123456",
- updated_at="2021-01-01",
- queued_for_crm_push=True,
- suggested_from_rule_engine_config_id="123456",
- email_unsubscribed=None,
- label_ids=[],
- has_pending_email_arcgate_request=True,
- has_email_arcgate_request=True,
- existence_level=None,
- email=None,
- email_from_customer=None,
- typed_custom_fields=[],
- custom_field_errors=None,
- salesforce_record_id=None,
- crm_record_url=None,
- email_status_unavailable_reason=None,
- email_true_status=None,
- updated_email_true_status=True,
- contact_rule_config_statuses=[],
- source_display_name=None,
- twitter_url=None,
- contact_campaign_statuses=[],
- state=None,
- city=None,
- country=None,
- account=None,
- contact_emails=[],
- organization=None,
- employment_history=[],
- time_zone=None,
- intent_strength=None,
- show_intent=True,
- phone_numbers=[],
- account_phone_note=None,
- free_domain=True,
- is_likely_to_engage=True,
- email_domain_catchall=True,
- contact_job_change_event=None,
- ),
+ _sample_contact(),
]
},
effect=BlockEffect.READ,
@@ -374,3 +221,84 @@ class SearchPeopleBlock(Block):
)
)
yield "people", people
+
+
+def _sample_contact() -> Contact:
+ return Contact(
+ contact_roles=[],
+ id="1",
+ name="John Doe",
+ first_name="John",
+ last_name="Doe",
+ linkedin_url="https://www.linkedin.com/in/johndoe",
+ title="Software Engineer",
+ organization_name="Google",
+ organization_id="123456",
+ contact_stage_id="1",
+ owner_id="1",
+ creator_id="1",
+ person_id="1",
+ email_needs_tickling=True,
+ source="apollo",
+ original_source="apollo",
+ headline="Software Engineer",
+ photo_url="https://www.linkedin.com/in/johndoe",
+ present_raw_address="123 Main St, Anytown, USA",
+ linkededin_uid="123456",
+ extrapolated_email_confidence=0.8,
+ salesforce_id="123456",
+ salesforce_lead_id="123456",
+ salesforce_contact_id="123456",
+ saleforce_account_id="123456",
+ crm_owner_id="123456",
+ created_at="2021-01-01",
+ emailer_campaign_ids=[],
+ direct_dial_status="active",
+ direct_dial_enrichment_failed_at="2021-01-01",
+ email_status="active",
+ email_source="apollo",
+ account_id="123456",
+ last_activity_date="2021-01-01",
+ hubspot_vid="123456",
+ hubspot_company_id="123456",
+ crm_id="123456",
+ sanitized_phone="123456",
+ merged_crm_ids="123456",
+ updated_at="2021-01-01",
+ queued_for_crm_push=True,
+ suggested_from_rule_engine_config_id="123456",
+ email_unsubscribed=None,
+ label_ids=[],
+ has_pending_email_arcgate_request=True,
+ has_email_arcgate_request=True,
+ existence_level=None,
+ email=None,
+ email_from_customer=None,
+ typed_custom_fields=[],
+ custom_field_errors=None,
+ salesforce_record_id=None,
+ crm_record_url=None,
+ email_status_unavailable_reason=None,
+ email_true_status=None,
+ updated_email_true_status=True,
+ contact_rule_config_statuses=[],
+ source_display_name=None,
+ twitter_url=None,
+ contact_campaign_statuses=[],
+ state=None,
+ city=None,
+ country=None,
+ account=None,
+ contact_emails=[],
+ organization=None,
+ employment_history=[],
+ time_zone=None,
+ intent_strength=None,
+ show_intent=True,
+ phone_numbers=[],
+ account_phone_note=None,
+ free_domain=True,
+ is_likely_to_engage=True,
+ email_domain_catchall=True,
+ contact_job_change_event=None,
+ )
diff --git a/autogpt_platform/backend/backend/blocks/apollo/person.py b/autogpt_platform/backend/backend/blocks/apollo/person.py
index afdd160f0f..0e1a46edd8 100644
--- a/autogpt_platform/backend/backend/blocks/apollo/person.py
+++ b/autogpt_platform/backend/backend/blocks/apollo/person.py
@@ -101,30 +101,10 @@ class GetPersonDetailBlock(Block):
test_output=[
(
"contact",
- Contact(
- id="1",
- name="John Doe",
- first_name="John",
- last_name="Doe",
- title="Software Engineer",
- organization_name="Google",
- linkedin_url="https://www.linkedin.com/in/johndoe",
- ),
+ _sample_contact(),
),
],
- test_mock={
- "enrich_person": lambda query, credentials: Contact(
- id="1",
- name="John Doe",
- first_name="John",
- last_name="Doe",
- title="Software Engineer",
- organization_name="Google",
- linkedin_url="https://www.linkedin.com/in/johndoe",
- )
- },
+ test_mock={"enrich_person": lambda query, credentials: _sample_contact()},
effect=BlockEffect.READ,
)
@@ -144,3 +124,16 @@ class GetPersonDetailBlock(Block):
) -> BlockOutput:
query = EnrichPersonRequest(**input_data.model_dump())
yield "contact", await self.enrich_person(query, credentials)
+
+
+def _sample_contact() -> Contact:
+ return Contact(
+ id="1",
+ name="John Doe",
+ first_name="John",
+ last_name="Doe",
+ title="Software Engineer",
+ organization_name="Google",
+ linkedin_url="https://www.linkedin.com/in/johndoe",
+ )