-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding qualified version for analytics
- Loading branch information
Showing
10 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
# Checking if current tag matches the package version | ||
current_tag=$(echo $GITHUB_REF | cut -d '/' -f 3 | sed -r 's/^v//') | ||
file_tag=$(grep '__version__ =' meilisearch/version.py | cut -d '=' -f 2- | tr -d ' ' | tr -d '"' | tr -d ',') | ||
if [ "$current_tag" != "$file_tag" ]; then | ||
echo "Error: the current tag does not match the version in package file(s)." | ||
echo "$current_tag vs $file_tag" | ||
exit 1 | ||
fi | ||
|
||
echo 'OK' | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from __future__ import annotations | ||
|
||
__version__ = "0.12.9" | ||
|
||
|
||
def qualified_version() -> str: | ||
"""Get the qualified version of this module.""" | ||
|
||
return f"Meilisearch DocsScraper (v{__version__})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MASTER_KEY = "masterKey" | ||
BASE_URL = "http://127.0.0.1:7700" | ||
|
||
DEFAULT_INDEX = 'index_uid' | ||
|
||
DEFAULT_DATA_DELETE = { | ||
"taskUid": 1, | ||
"indexUid": DEFAULT_INDEX, | ||
"status": "enqueued", | ||
"type": "indexDeletion", | ||
"enqueuedAt": "2023-03-30T13:24:01.789654093Z" | ||
} | ||
DEFAULT_DATA_PATCH = { | ||
"taskUid": 1, | ||
"indexUid": DEFAULT_INDEX, | ||
"status": "enqueued", | ||
"type": "settingsUpdate", | ||
"enqueuedAt": "2023-03-30T13:24:01.789654093Z" | ||
} | ||
|
||
DEFAULT_ACCEPTED_STATUS = 202 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# coding: utf-8 | ||
import json | ||
from unittest.mock import patch | ||
|
||
import requests | ||
|
||
from scraper.src.meilisearch_helper import MeiliSearchHelper | ||
from scraper.src.config.version import __version__ | ||
from tests.meilisearch_helper import common | ||
|
||
|
||
class TestMeilisearchHelper: | ||
@patch("requests.delete") | ||
@patch("requests.patch") | ||
def test_use_meilisearch_default(self, mock_delete, mock_patch): | ||
mock_delete.configure_mock(__name__="delete") | ||
mock_response = requests.models.Response() | ||
mock_response.status_code = common.DEFAULT_ACCEPTED_STATUS | ||
mock_response._content = json.dumps(common.DEFAULT_DATA_DELETE).encode('utf-8') | ||
mock_delete.return_value = mock_response | ||
|
||
mock_patch.configure_mock(__name__="patch") | ||
mock_response = requests.models.Response() | ||
mock_response.status_code = common.DEFAULT_ACCEPTED_STATUS | ||
mock_response._content = json.dumps(common.DEFAULT_DATA_DELETE).encode('utf-8') | ||
mock_patch.return_value = mock_response | ||
""" Should set the `User-Agent` doscraper by default """ | ||
# When | ||
actual = MeiliSearchHelper( | ||
common.BASE_URL, | ||
common.MASTER_KEY, | ||
common.DEFAULT_INDEX, | ||
MeiliSearchHelper.SETTINGS | ||
) | ||
|
||
# Then | ||
assert actual.meilisearch_client.http.headers['User-Agent'] == f"Meilisearch Python (v0.27.0);Meilisearch DocsScraper (v{__version__})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# coding: utf-8 | ||
import re | ||
|
||
from scraper.src.config.version import __version__ | ||
|
||
|
||
class TestInit: | ||
def test_get_version(self): | ||
assert re.match(r"^(\d+\.)?(\d+\.)?(\*|\d+)$", __version__) |