-
Notifications
You must be signed in to change notification settings - Fork 1
Add UTF-8 encoding support for query data and update version to 2.1.0 #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a7f9179
Add UTF-8 encoding support for query data and update version to 2.1.0
18525ae
Update Python version requirements to 3.10 in workflow, README, and p…
087fbb9
Refactor user creation statements to include password in SQL commands…
ee6d93d
Add TIMBR_USER_PASSWORD to test configuration and update user creatio…
04eecb3
Enhance UTF-8 encoding support in run_query and add tests for unicode…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Binary file not shown.
This file contains hidden or 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 hidden or 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,78 @@ | ||
| import pytest | ||
| from pytimbr_api.timbr_http_connector import run_query | ||
|
|
||
|
|
||
| def test_run_query_with_unicode_characters(test_config): | ||
| """Test that queries with unicode characters are properly encoded to UTF-8.""" | ||
| url = test_config['url'] | ||
| ontology = test_config['ontology'] | ||
| token = test_config['token'] | ||
|
|
||
| # Query with unicode characters - using simple SELECT with unicode strings | ||
| # This tests that UTF-8 encoding works without requiring specific tables | ||
| query_with_unicode = "SELECT '测试' as chinese, 'café' as french, '😀' as emoji" | ||
|
semantiDan marked this conversation as resolved.
|
||
|
|
||
| results = run_query(url, ontology, token, query_with_unicode) | ||
|
|
||
| assert results is not None, "Results should not be None for unicode query" | ||
| assert len(results) > 0, "Results should contain data" | ||
| # Verify unicode characters are correctly processed in results | ||
| first_row = results[0] | ||
| assert first_row['chinese'] == '测试', "Chinese characters should be preserved" | ||
| assert first_row['french'] == 'café', "French accented characters should be preserved" | ||
| assert first_row['emoji'] == '😀', "Emoji should be preserved" | ||
|
|
||
|
|
||
| def test_run_query_with_already_encoded_bytes(test_config): | ||
| """Test that queries already encoded as bytes are handled correctly.""" | ||
| url = test_config['url'] | ||
| ontology = test_config['ontology'] | ||
| token = test_config['token'] | ||
|
|
||
| # Query already encoded as bytes | ||
| query_as_bytes = b"SELECT 1" | ||
|
|
||
| results = run_query(url, ontology, token, query_as_bytes) | ||
|
|
||
| assert results is not None, "Results should not be None for bytes query" | ||
| assert len(results) > 0, "Results should contain data" | ||
|
|
||
|
|
||
| def test_run_query_with_special_sql_characters(test_config): | ||
| """Test that queries with special SQL characters are properly encoded.""" | ||
| url = test_config['url'] | ||
| ontology = test_config['ontology'] | ||
| token = test_config['token'] | ||
|
|
||
| # Query with special characters that need proper encoding | ||
| query_with_special_chars = "SELECT 'O''Brien' as name, '©' as copyright" | ||
|
semantiDan marked this conversation as resolved.
|
||
|
|
||
| results = run_query(url, ontology, token, query_with_special_chars) | ||
|
|
||
| assert results is not None, "Results should not be None for query with special characters" | ||
| assert len(results) > 0, "Results should contain data" | ||
| # Verify special characters are correctly processed in results | ||
| first_row = results[0] | ||
| assert first_row['name'] == "O'Brien", "Apostrophe in name should be preserved" | ||
| assert first_row['copyright'] == '©', "Copyright symbol should be preserved" | ||
|
|
||
|
|
||
| def test_run_query_with_multilingual_text(test_config): | ||
| """Test that queries with multiple languages are properly encoded.""" | ||
| url = test_config['url'] | ||
| ontology = test_config['ontology'] | ||
| token = test_config['token'] | ||
|
|
||
| # Query with multiple languages (Latin, Cyrillic, Arabic, Japanese) | ||
| query_multilingual = "SELECT 'Hello' as english, 'Привет' as russian, 'مرحبا' as arabic, 'こんにちは' as japanese" | ||
|
semantiDan marked this conversation as resolved.
|
||
|
|
||
| results = run_query(url, ontology, token, query_multilingual) | ||
|
|
||
| assert results is not None, "Results should not be None for multilingual query" | ||
| assert len(results) > 0, "Results should contain data" | ||
| # Verify multilingual characters are correctly processed in results | ||
| first_row = results[0] | ||
| assert first_row['english'] == 'Hello', "English text should be preserved" | ||
| assert first_row['russian'] == 'Привет', "Russian Cyrillic text should be preserved" | ||
| assert first_row['arabic'] == 'مرحبا', "Arabic text should be preserved" | ||
| assert first_row['japanese'] == 'こんにちは', "Japanese text should be preserved" | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.