Skip to content

Commit

Permalink
Setup CI infrastructure for automated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aecio committed May 23, 2024
1 parent 02447b5 commit 2da92ef
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest jupyter
- name: Install the bdikit package
run: |
pip install -e .
- name: Test with pytest
run: |
pytest
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
all: test

PHONY: test

test:
python3 -m pytest
Empty file added tests/__init__.py
Empty file.
39 changes: 39 additions & 0 deletions tests/test_column_mapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import unittest
import pandas as pd
from bdikit.mapping_algorithms.column_mapping.algorithms import (
SimFloodAlgorithm,
JaccardDistanceAlgorithm,
DistributionBasedAlgorithm,
ComaAlgorithm,
CupidAlgorithm,
)


class ColumnMappingTest(unittest.TestCase):
def test_basic_column_mapping_algorithms(self):
for ColumnMatcher in [
SimFloodAlgorithm,
JaccardDistanceAlgorithm,
DistributionBasedAlgorithm,
ComaAlgorithm,
CupidAlgorithm,
]:
# given
table1 = pd.DataFrame(
{"column_1": ["a1", "b1", "c1"], "col_2": ["a2", "b2", "c2"]}
)
table2 = pd.DataFrame(
{"column_1a": ["a1", "b1", "c1"], "col2": ["a2", "b2", "c2"]}
)
column_matcher = ColumnMatcher(dataset=table1, global_table=table2)

# when
mapping = column_matcher.map()

# then
print(mapping)
self.assertEqual(
{"column_1": "column_1a", "col_2": "col2"},
mapping,
msg=f"{ColumnMatcher.__name__} failed to map columns",
)

0 comments on commit 2da92ef

Please sign in to comment.