コード例 #1
0
 def test_update_insights_streams(self, api, config):
     config["custom_insights"] = [
         {"name": "test", "fields": ["account_id"], "breakdowns": ["ad_format_asset"], "action_breakdowns": ["action_device"]},
     ]
     streams = SourceFacebookMarketing().streams(config)
     config = ConnectorConfig.parse_obj(config)
     insights_args = dict(
         api=api,
         start_date=config.start_date,
         end_date=config.end_date,
     )
     assert SourceFacebookMarketing()._update_insights_streams(
         insights=config.custom_insights, default_args=insights_args, streams=streams
     )
コード例 #2
0
    def test_check_connection_invalid_config(self, api, config, logger_mock):
        config.pop("start_date")

        with pytest.raises(pydantic.ValidationError):
            SourceFacebookMarketing().check_connection(logger_mock, config=config)

        assert not api.called
コード例 #3
0
    def test_check_connection_empty_config(self, api, logger_mock):
        config = {}

        with pytest.raises(pydantic.ValidationError):
            SourceFacebookMarketing().check_connection(logger_mock, config=config)

        assert not api.called
コード例 #4
0
    def test_check_connection_ok(self, api, config, logger_mock):
        ok, error_msg = SourceFacebookMarketing().check_connection(logger_mock, config=config)

        assert ok
        assert not error_msg
        api.assert_called_once_with(account_id="123", access_token="TOKEN")
        logger_mock.info.assert_called_once_with(f"Select account {api.return_value.account}")
コード例 #5
0
#
# Copyright (c) 2020 Airbyte
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

import sys

from base_python.entrypoint import launch
from source_facebook_marketing import SourceFacebookMarketing

if __name__ == "__main__":
    source = SourceFacebookMarketing()
    launch(source, sys.argv[1:])
コード例 #6
0
    def test_spec(self):
        spec = SourceFacebookMarketing().spec()

        assert isinstance(spec, ConnectorSpecification)
コード例 #7
0
    def test_streams(self, config, api):
        streams = SourceFacebookMarketing().streams(config)

        assert len(streams) == 15
コード例 #8
0
    def test_check_connection_exception(self, api, config, logger_mock):
        api.side_effect = RuntimeError("Something went wrong!")

        with pytest.raises(RuntimeError, match="Something went wrong!"):
            SourceFacebookMarketing().check_connection(logger_mock, config=config)
コード例 #9
0
    def test_check_connection_end_date_before_start_date(self, api, config, logger_mock):
        config["start_date"] = "2019-10-10T00:00:00"
        config["end_date"] = "2019-10-09T00:00:00"

        with pytest.raises(ValueError, match="end_date must be equal or after start_date."):
            SourceFacebookMarketing().check_connection(logger_mock, config=config)