예제 #1
0
    def test_generates_the_correct_postgres_uri(self, basehook_mock):
        connection_mock = mock.Mock(login='******',
                                    password='******',
                                    host='host',
                                    port=1234,
                                    schema='schema')
        basehook_mock.get_connection.return_value = connection_mock

        uri = helpers.get_postgres_uri('connection')
        assert uri == 'postgres://*****:*****@host:1234/schema'
예제 #2
0
    def test_execute_calls_pg_dump_correctly(self, get_connection_mock,
                                             boto3_mock, popen_mock):
        operator = PostgresToS3Transfer(task_id='task_id',
                                        postgres_conn_id='postgres_conn_id',
                                        s3_conn_id='s3_conn_id',
                                        s3_url='s3://bucket/key')

        operator.execute(None)

        expected_command = [
            'pg_dump',
            '-Fc',
            helpers.get_postgres_uri(operator.postgres_conn_id),
        ]
        popen_mock.assert_called_with(expected_command, stdout=subprocess.PIPE)
예제 #3
0
    def test_uses_port_5432_by_default(self, basehook_mock):
        connection_mock = mock.Mock(port=None)
        basehook_mock.get_connection.return_value = connection_mock

        uri = helpers.get_postgres_uri('connection')
        assert ':5432' in uri