Skip to content

Commit 377817b

Browse files
committed
test with airflow
1 parent 49d522a commit 377817b

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ jobs:
1616
# fail-fast: true
1717
# matrix:
1818
# os: [ubuntu-latest]
19-
# # numpy-version: ['<1.19', '<1.20', '>=1.20']
2019
# python-version: ['3.9', '3.10', '3.11', '3.12']
21-
# astropy-version: ['<6.0', '<6.1', '<7.0']
20+
# airflow-version: ['<2.10', '<2.11']
2221

2322
# steps:
2423
# - name: Checkout code
@@ -32,8 +31,8 @@ jobs:
3231
# - name: Install Python dependencies
3332
# run: |
3433
# python -m pip install --upgrade pip setuptools wheel
35-
# python -m pip install pytest pyyaml jinja2 numpy\<2.0
36-
# python -m pip install "astropy${{ matrix.astropy-version }}"
34+
# python -m pip install pytest
35+
# python -m pip install "apache-airflow${{ matrix.airflow-version }}"
3736
# - name: Run the test
3837
# run: pytest
3938

@@ -45,6 +44,7 @@ jobs:
4544
matrix:
4645
os: [ubuntu-latest]
4746
python-version: ['3.9']
47+
airflow-version: ['<2.10']
4848

4949
steps:
5050
- name: Checkout code
@@ -59,6 +59,7 @@ jobs:
5959
run: |
6060
python -m pip install --upgrade pip setuptools wheel
6161
python -m pip install pytest pytest-cov coveralls
62+
python -m pip install "apache-airflow${{ matrix.airflow-version }}"
6263
- name: Run the test with coverage
6364
run: pytest --cov
6465
# - name: Coveralls

dlairflow/test/test_postgresql.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Licensed under a BSD-style 3-clause license - see LICENSE.md.
2+
# -*- coding: utf-8 -*-
3+
"""Test dlairflow.postgresql.
4+
"""
5+
import os
6+
from ..postgresql import pg_dump_schema, pg_restore_schema
7+
from airflow.hooks.base import BaseHook
8+
9+
10+
class MockConnection(object):
11+
12+
def __init__(self, connection):
13+
foo = connection.split(',')
14+
self.login = foo[0]
15+
self.password = foo[1]
16+
self.host = foo[2]
17+
self.schema = foo[3]
18+
return
19+
20+
21+
def test_pg_dump_schema(monkeypatch):
22+
"""Test pg_dump task.
23+
"""
24+
def mock_connection(connection):
25+
conn = MockConnection(connection)
26+
return conn
27+
28+
monkeypatch.setattr(BaseHook, "get_connection", mock_connection)
29+
30+
test_operator = pg_dump_schema("login,password,host,schema")
31+
32+
print(dir(test_operator))

0 commit comments

Comments
 (0)