Skip to content

Commit

Permalink
Merge pull request #13 from shashank-boyapally/fmatch
Browse files Browse the repository at this point in the history
unit test refactor mock
  • Loading branch information
shashank-boyapally authored Jan 23, 2024
2 parents 0e42a21 + e9e56fb commit 00f64f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ jobs:
test:
runs-on: ubuntu-latest

env:
ES_SERVER: ${{ secrets.ES_SERVER }}

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
11 changes: 7 additions & 4 deletions fmatch/tests/test_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pylint: disable = missing-function-docstring
#pylint: disable = import-error
import os
from unittest.mock import patch

from elasticsearch.exceptions import NotFoundError
import pytest
Expand All @@ -14,6 +15,7 @@
from fmatch.matcher import Matcher



@pytest.fixture
def matcher_instance():
sample_output = {
Expand All @@ -24,10 +26,11 @@ def matcher_instance():
]
}
}
match = Matcher(index="perf-scale-ci")
match.es.search = lambda *args, **kwargs: sample_output
return match

with patch('fmatch.matcher.Elasticsearch') as mock_es:
mock_es_instance = mock_es.return_value
mock_es_instance.search.return_value = sample_output
match = Matcher(index="perf-scale-ci")
return match

def test_get_metadata_by_uuid_found(matcher_instance):
uuid = "test_uuid"
Expand Down

0 comments on commit 00f64f3

Please sign in to comment.