Skip to content

Commit 84bbfb2

Browse files
committed
WIP
1 parent 97ed8aa commit 84bbfb2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/unit/packaging/test_services.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,13 @@ def test_check_project_name_typosquatting_prohibited(self, db_session):
10591059
with pytest.raises(ProjectNameUnavailableTypoSquattingError):
10601060
service.check_project_name_after_commit("numpi")
10611061

1062+
def test_check_project_name_typosquatting_no_typo(self, db_session):
1063+
# TODO: Update this test once we have a dynamic TopN approach
1064+
service = ProjectService(session=db_session)
1065+
ProhibitedProjectFactory.create(name="numpy")
1066+
1067+
assert service.check_project_name_after_commit("foobar") is None
1068+
10621069
def test_check_project_name_ok(self, db_session):
10631070
service = ProjectService(session=db_session)
10641071

tests/unit/packaging/test_typosnyper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13+
import pretend
1314
import pytest
1415

16+
from warehouse.packaging import typosnyper
17+
from warehouse.packaging.models import Project
1518
from warehouse.packaging.typosnyper import typo_check_name
1619

1720

1821
@pytest.mark.parametrize(
1922
("name", "expected"),
2023
[
24+
("x", None), # Pass, shorter than 4 characters
2125
("numpy", None), # Pass, no typos, exists
2226
("NuMpy", None), # Pass, same as `numpy` after canonicalization
2327
("nuumpy", ("repeated_characters", "numpy")),
@@ -43,3 +47,13 @@ def test_typo_check_name(name, expected):
4347
}
4448

4549
assert typo_check_name(name, corpus=test_names_corpus) == expected
50+
51+
52+
def test_check_typo_after_commit(db_request, monkeypatch):
53+
# db_request.config.find_service_factory = pretend.raiser(LookupError)
54+
55+
project = Project(name="foobar")
56+
db_request.db.add(project)
57+
db_request.db.commit()
58+
59+
assert typosnyper.check_typo_after_commit.calls == []

0 commit comments

Comments
 (0)