-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(search): search all repositories #9949
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
+163
−67
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dc2a721
fix(sources): allow list of tokens as query
abn 6d58573
feat(search): search all repositories
abn 8d0920a
doc: add PyPI search capability removal notice
abn 30a8d54
fix(search): do not display duplicates
abn 1fa647c
test(search): add coverage for multiple args
abn 7a7890f
feat(search): use tabular output and incl. source
abn c6224c8
Merge branch 'main' into legacy-repo-search
Secrus 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
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
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 |
|---|---|---|
| @@ -1,95 +1,150 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import re | ||
|
|
||
| from pathlib import Path | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| import pytest | ||
|
|
||
| from poetry.repositories.pypi_repository import PyPiRepository | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| import httpretty | ||
|
|
||
| from cleo.testers.command_tester import CommandTester | ||
|
|
||
| from poetry.poetry import Poetry | ||
| from poetry.repositories.legacy_repository import LegacyRepository | ||
| from tests.types import CommandTesterFactory | ||
|
|
||
| TESTS_DIRECTORY = Path(__file__).parent.parent.parent | ||
| FIXTURES_DIRECTORY = ( | ||
| TESTS_DIRECTORY / "repositories" / "fixtures" / "pypi.org" / "search" | ||
| ) | ||
| SQLALCHEMY_SEARCH_OUTPUT_PYPI = """\ | ||
| Package Version Source Description | ||
| broadway-sqlalchemy 0.0.1 PyPI A broadway extension wrapping Flask-SQLAlchemy | ||
| cherrypy-sqlalchemy 0.5.3 PyPI Use SQLAlchemy with CherryPy | ||
| graphene-sqlalchemy 2.2.2 PyPI Graphene SQLAlchemy integration | ||
| jsonql-sqlalchemy 1.0.1 PyPI Simple JSON-Based CRUD Query Language for SQLAlchemy | ||
| paginate-sqlalchemy 0.3.0 PyPI Extension to paginate.Page that supports SQLAlchemy queries | ||
| sqlalchemy 1.3.10 PyPI Database Abstraction Library | ||
| sqlalchemy-audit 0.1.0 PyPI sqlalchemy-audit provides an easy way to set up revision tracking for your data. | ||
| sqlalchemy-dao 1.3.1 PyPI Simple wrapper for sqlalchemy. | ||
| sqlalchemy-diff 0.1.3 PyPI Compare two database schemas using sqlalchemy. | ||
| sqlalchemy-equivalence 0.1.1 PyPI Provides natural equivalence support for SQLAlchemy declarative models. | ||
| sqlalchemy-filters 0.10.0 PyPI A library to filter SQLAlchemy queries. | ||
| sqlalchemy-nav 0.0.2 PyPI SQLAlchemy-Nav provides SQLAlchemy Mixins for creating navigation bars compatible with Bootstrap | ||
| sqlalchemy-plus 0.2.0 PyPI Create Views and Materialized Views with SqlAlchemy | ||
| sqlalchemy-repr 0.0.1 PyPI Automatically generates pretty repr of a SQLAlchemy model. | ||
| sqlalchemy-schemadisplay 1.3 PyPI Turn SQLAlchemy DB Model into a graph | ||
| sqlalchemy-sqlany 1.0.3 PyPI SAP Sybase SQL Anywhere dialect for SQLAlchemy | ||
| sqlalchemy-traversal 0.5.2 PyPI UNKNOWN | ||
| sqlalchemy-utcdatetime 1.0.4 PyPI Convert to/from timezone aware datetimes when storing in a DBMS | ||
| sqlalchemy-wrap 2.1.7 PyPI Python wrapper for the CircleCI API | ||
| transmogrify-sqlalchemy 1.0.2 PyPI Feed data from SQLAlchemy into a transmogrifier pipeline | ||
| """ | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def tester(command_tester_factory: CommandTesterFactory) -> CommandTester: | ||
| return command_tester_factory("search") | ||
|
|
||
|
|
||
| def test_search(tester: CommandTester, http: type[httpretty.httpretty]) -> None: | ||
| def clean_output(text: str) -> str: | ||
| return re.sub(r"\s+\n", "\n", text) | ||
|
|
||
|
|
||
| def test_search( | ||
| tester: CommandTester, http: type[httpretty.httpretty], poetry: Poetry | ||
| ) -> None: | ||
| # we expect PyPI in the default behaviour | ||
| poetry.pool.add_repository(PyPiRepository()) | ||
|
|
||
| tester.execute("sqlalchemy") | ||
|
|
||
| expected = """ | ||
| sqlalchemy (1.3.10) | ||
| Database Abstraction Library | ||
| output = clean_output(tester.io.fetch_output()) | ||
|
|
||
| assert output == SQLALCHEMY_SEARCH_OUTPUT_PYPI | ||
|
|
||
| sqlalchemy-dao (1.3.1) | ||
| Simple wrapper for sqlalchemy. | ||
|
|
||
| graphene-sqlalchemy (2.2.2) | ||
| Graphene SQLAlchemy integration | ||
| def test_search_empty_results( | ||
| tester: CommandTester, | ||
| http: type[httpretty.httpretty], | ||
| poetry: Poetry, | ||
| legacy_repository: LegacyRepository, | ||
| ) -> None: | ||
| poetry.pool.add_repository(legacy_repository) | ||
|
|
||
| sqlalchemy-utcdatetime (1.0.4) | ||
| Convert to/from timezone aware datetimes when storing in a DBMS | ||
| tester.execute("does-not-exist") | ||
|
|
||
| paginate-sqlalchemy (0.3.0) | ||
| Extension to paginate.Page that supports SQLAlchemy queries | ||
| output = tester.io.fetch_output() | ||
| assert output.strip() == "No matching packages were found." | ||
|
|
||
| sqlalchemy-audit (0.1.0) | ||
| sqlalchemy-audit provides an easy way to set up revision tracking for your data. | ||
|
|
||
| transmogrify-sqlalchemy (1.0.2) | ||
| Feed data from SQLAlchemy into a transmogrifier pipeline | ||
| def test_search_with_legacy_repository( | ||
| tester: CommandTester, | ||
| http: type[httpretty.httpretty], | ||
| poetry: Poetry, | ||
| legacy_repository: LegacyRepository, | ||
| ) -> None: | ||
| poetry.pool.add_repository(PyPiRepository()) | ||
| poetry.pool.add_repository(legacy_repository) | ||
abn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| sqlalchemy-schemadisplay (1.3) | ||
| Turn SQLAlchemy DB Model into a graph | ||
| tester.execute("sqlalchemy") | ||
|
|
||
| sqlalchemy-traversal (0.5.2) | ||
| UNKNOWN | ||
| line_before = " sqlalchemy-filters 0.10.0 PyPI A library to filter SQLAlchemy queries." | ||
| additional_line = " sqlalchemy-legacy 4.3.4 legacy" | ||
| expected = SQLALCHEMY_SEARCH_OUTPUT_PYPI.replace( | ||
| line_before, f"{line_before}\n{additional_line}" | ||
| ) | ||
|
|
||
| sqlalchemy-filters (0.10.0) | ||
| A library to filter SQLAlchemy queries. | ||
| output = clean_output(tester.io.fetch_output()) | ||
|
|
||
| sqlalchemy-wrap (2.1.7) | ||
| Python wrapper for the CircleCI API | ||
| assert output == expected | ||
|
|
||
| sqlalchemy-nav (0.0.2) | ||
| SQLAlchemy-Nav provides SQLAlchemy Mixins for creating navigation bars compatible with\ | ||
| Bootstrap | ||
|
|
||
| sqlalchemy-repr (0.0.1) | ||
| Automatically generates pretty repr of a SQLAlchemy model. | ||
| def test_search_only_legacy_repository( | ||
| tester: CommandTester, | ||
| http: type[httpretty.httpretty], | ||
| poetry: Poetry, | ||
| legacy_repository: LegacyRepository, | ||
| ) -> None: | ||
| poetry.pool.add_repository(legacy_repository) | ||
|
|
||
| sqlalchemy-diff (0.1.3) | ||
| Compare two database schemas using sqlalchemy. | ||
| tester.execute("ipython") | ||
|
|
||
| sqlalchemy-equivalence (0.1.1) | ||
| Provides natural equivalence support for SQLAlchemy declarative models. | ||
| expected = """\ | ||
| Package Version Source Description | ||
| ipython 5.7.0 legacy | ||
| ipython 7.5.0 legacy | ||
| """ | ||
|
|
||
| broadway-sqlalchemy (0.0.1) | ||
| A broadway extension wrapping Flask-SQLAlchemy | ||
| output = clean_output(tester.io.fetch_output()) | ||
| assert output == expected | ||
|
|
||
| jsonql-sqlalchemy (1.0.1) | ||
| Simple JSON-Based CRUD Query Language for SQLAlchemy | ||
|
|
||
| sqlalchemy-plus (0.2.0) | ||
| Create Views and Materialized Views with SqlAlchemy | ||
| def test_search_multiple_queries( | ||
| tester: CommandTester, | ||
| http: type[httpretty.httpretty], | ||
| poetry: Poetry, | ||
| legacy_repository: LegacyRepository, | ||
| ) -> None: | ||
| poetry.pool.add_repository(legacy_repository) | ||
|
|
||
| cherrypy-sqlalchemy (0.5.3) | ||
| Use SQLAlchemy with CherryPy | ||
| tester.execute("ipython isort") | ||
|
|
||
| sqlalchemy-sqlany (1.0.3) | ||
| SAP Sybase SQL Anywhere dialect for SQLAlchemy | ||
| expected = """\ | ||
| Package Version Source Description | ||
| ipython 5.7.0 legacy | ||
| ipython 7.5.0 legacy | ||
| isort 4.3.4 legacy | ||
| isort-metadata 4.3.4 legacy | ||
| """ | ||
|
|
||
| output = tester.io.fetch_output() | ||
| output = clean_output(tester.io.fetch_output()) | ||
|
|
||
| assert output == expected | ||
| # we use a set here to avoid ordering issues | ||
| assert set(output.split("\n")) == set(expected.split("\n")) | ||
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,11 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Links for sqlalchemy-legacy</title> | ||
| </head> | ||
| <body> | ||
| <h1>Links for sqlalchemy-legacy</h1> | ||
| <a href="https://files.pythonhosted.org/packages/41/d8/a945da414f2adc1d9e2f7d6e7445b27f2be42766879062a2e63616ad4199/sqlalchemy-legacy-4.3.4-py2-none-any.whl#sha256=383c39c10b5db83e8d150ac5b84d74bda96e3a1b06a30257f022dcbcd21f54b9">sqlalchemy-legacy-4.3.4-py2-none-any.whl</a><br/> | ||
| </body> | ||
| </html> | ||
| <!--SERIAL 3575149--> |
Oops, something went wrong.
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.