Skip to content

Commit

Permalink
unit test refactor mock
Browse files Browse the repository at this point in the history
  • Loading branch information
shashank-boyapally committed Jan 22, 2024
1 parent ee763c7 commit e9e56fb
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 e9e56fb

Please sign in to comment.