Skip to content

Commit 00f64f3

Browse files
Merge pull request #13 from shashank-boyapally/fmatch
unit test refactor mock
2 parents 0e42a21 + e9e56fb commit 00f64f3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

.github/workflows/unit_test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88

9-
env:
10-
ES_SERVER: ${{ secrets.ES_SERVER }}
11-
129
steps:
1310
- name: Checkout code
1411
uses: actions/checkout@v2

fmatch/tests/test_matcher.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pylint: disable = missing-function-docstring
66
#pylint: disable = import-error
77
import os
8+
from unittest.mock import patch
89

910
from elasticsearch.exceptions import NotFoundError
1011
import pytest
@@ -14,6 +15,7 @@
1415
from fmatch.matcher import Matcher
1516

1617

18+
1719
@pytest.fixture
1820
def matcher_instance():
1921
sample_output = {
@@ -24,10 +26,11 @@ def matcher_instance():
2426
]
2527
}
2628
}
27-
match = Matcher(index="perf-scale-ci")
28-
match.es.search = lambda *args, **kwargs: sample_output
29-
return match
30-
29+
with patch('fmatch.matcher.Elasticsearch') as mock_es:
30+
mock_es_instance = mock_es.return_value
31+
mock_es_instance.search.return_value = sample_output
32+
match = Matcher(index="perf-scale-ci")
33+
return match
3134

3235
def test_get_metadata_by_uuid_found(matcher_instance):
3336
uuid = "test_uuid"

0 commit comments

Comments
 (0)