Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit test refactor mock #13

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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