Skip to content

Commit

Permalink
Source: Facebook Marketing use latest version of facebook_bussiness d…
Browse files Browse the repository at this point in the history
…ep lib (airbytehq#4136)

* use latest version of fb dep lib

* update docker file

* Update version as well.

* Remove deprecated fields. Make api version a parameter.

* Update airbyte-integrations/connectors/source-facebook-marketing/Dockerfile

Co-authored-by: LiRen Tu <tuliren.git@outlook.com>

Co-authored-by: Davin Chia <davinchia@gmail.com>
Co-authored-by: LiRen Tu <tuliren.git@outlook.com>
  • Loading branch information
3 people authored Jun 16, 2021
1 parent 85ee72d commit 5d045a8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"sourceDefinitionId": "e7778cfc-e97c-4458-9ecb-b4f2bba8946c",
"name": "Facebook Marketing",
"dockerRepository": "airbyte/source-facebook-marketing",
"dockerImageTag": "0.2.9",
"dockerImageTag": "0.2.10",
"documentationUrl": "https://hub.docker.com/r/airbyte/source-facebook-marketing",
"icon": "facebook.svg"
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
- sourceDefinitionId: e7778cfc-e97c-4458-9ecb-b4f2bba8946c
name: Facebook Marketing
dockerRepository: airbyte/source-facebook-marketing
dockerImageTag: 0.2.9
dockerImageTag: 0.2.10
documentationUrl: https://hub.docker.com/r/airbyte/source-facebook-marketing
icon: facebook.svg
- sourceDefinitionId: 36c891d9-4bd9-43ac-bad2-10e12756272c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.2.10
Update version of facebook_bussiness to 11.0

## 0.2.9
Add 80000 as a rate-limiting error code (#3996)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.9
LABEL io.airbyte.version=0.2.10
LABEL io.airbyte.name=airbyte/source-facebook-marketing
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,6 @@
"cost_per_outbound_click": {
"$ref": "ads_action_stats.json"
},
"cost_per_store_visit_action": {
"$ref": "ads_action_stats.json"
},
"cost_per_thruplay": {
"$ref": "ads_action_stats.json"
},
Expand Down Expand Up @@ -807,9 +804,6 @@
"spend": {
"type": ["null", "number"]
},
"store_visit_actions": {
"$ref": "ads_action_stats.json"
},
"unique_actions": {
"$ref": "ads_action_stats.json"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
MAIN_REQUIREMENTS = [
"airbyte-cdk~=0.1",
"cached_property~=1.5",
"facebook_business~=10.0",
"facebook_business~=11.0",
"pendulum~=1.2",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from facebook_business.exceptions import FacebookRequestError
from source_facebook_marketing.client import Client

FB_API_VERSION = "11.0"

@pytest.fixture(scope="session", name="account_id")
def account_id_fixture():
Expand All @@ -50,7 +51,7 @@ def mock_default_sleep_interval(mocker):
@pytest.fixture(name="client")
def client_fixture(some_config, requests_mock, fb_account_response):
client = Client(**some_config)
requests_mock.register_uri("GET", FacebookSession.GRAPH + "/v10.0/me/adaccounts", [fb_account_response])
requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v{FB_API_VERSION}/me/adaccounts", [fb_account_response])
return client


Expand Down Expand Up @@ -102,9 +103,9 @@ def test_limit_reached(self, requests_mock, client, fb_call_rate_response, accou
},
]

requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v10.0/act_{account_id}/campaigns", campaign_responses)
requests_mock.register_uri("GET", FacebookSession.GRAPH + "/v10.0/1/", [{"status_code": 200}])
requests_mock.register_uri("GET", FacebookSession.GRAPH + "/v10.0/2/", [{"status_code": 200}])
requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v{FB_API_VERSION}/act_{account_id}/campaigns", campaign_responses)
requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v{FB_API_VERSION}/1/", [{"status_code": 200}])
requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v{FB_API_VERSION}/2/", [{"status_code": 200}])

records = list(client.read_stream(AirbyteStream(name="campaigns", json_schema={})))

Expand Down Expand Up @@ -149,8 +150,8 @@ def test_batch_limit_reached(self, requests_mock, client, fb_call_rate_response,
},
]

requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v10.0/act_{account_id}/adcreatives", responses)
requests_mock.register_uri("POST", FacebookSession.GRAPH + "/v10.0/", batch_responses)
requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v{FB_API_VERSION}/act_{account_id}/adcreatives", responses)
requests_mock.register_uri("POST", FacebookSession.GRAPH + f"/v{FB_API_VERSION}/", batch_responses)

records = list(client.read_stream(AirbyteStream(name="adcreatives", json_schema={})))

Expand All @@ -166,7 +167,7 @@ def test_server_error(self, requests_mock, client, account_id):
},
]

requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v10.0/act_{account_id}/campaigns", responses)
requests_mock.register_uri("GET", FacebookSession.GRAPH + f"/v{FB_API_VERSION}/act_{account_id}/campaigns", responses)

with pytest.raises(FacebookRequestError):
list(client.read_stream(AirbyteStream(name="campaigns", json_schema={})))

0 comments on commit 5d045a8

Please sign in to comment.