-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): added and adjusted tests for project command
- Loading branch information
Showing
8 changed files
with
16,748 additions
and
93,581 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
20,306 changes: 14,548 additions & 5,758 deletions
20,306
api/outdated/outdated/tests/cassettes/test_sync_project_endpoint.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
3,054 changes: 1,658 additions & 1,396 deletions
3,054
api/outdated/outdated/tests/cassettes/test_syncproject.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
85,831 changes: 0 additions & 85,831 deletions
85,831
api/outdated/outdated/tests/cassettes/test_syncprojects.yaml
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,15 @@ | ||
from unittest.mock import ANY | ||
|
||
import pytest | ||
from django.core.management import call_command | ||
|
||
from outdated.outdated.synchroniser import Synchroniser | ||
|
||
|
||
@pytest.mark.vcr() | ||
@pytest.mark.django_db(transaction=True) | ||
def test_syncproject(project_factory): | ||
call_command("syncproject", "foo") | ||
|
||
def test_syncproject(project_factory, mocker): | ||
project = project_factory.create(repo="https://github.com/projectcaluma/caluma") | ||
|
||
sync_init_mocker = mocker.spy(Synchroniser, "__init__") | ||
call_command("syncproject", project.name) | ||
assert project.versioned_dependencies.count() > 0 | ||
|
||
|
||
@pytest.mark.vcr() | ||
@pytest.mark.django_db(transaction=True) | ||
def test_syncprojects(project_factory): | ||
projects = [ | ||
project_factory(repo=f"https://github.com/adfinis/{project}") | ||
for project in ["outdated", "mysagw"] | ||
] | ||
|
||
call_command("syncprojects") | ||
for project in projects: | ||
assert project.versioned_dependencies.count() > 0 | ||
sync_init_mocker.assert_called_once_with(ANY, project) |
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 @@ | ||
from unittest.mock import call | ||
|
||
import pytest | ||
|
||
from outdated.commands import ProjectCommand | ||
|
||
|
||
@pytest.mark.parametrize("all", [True, False]) | ||
def test_command_handle(transactional_db, project_factory, all, mocker): | ||
projects = project_factory.create_batch(5) | ||
argv = ["", "project-command-test"] | ||
handle_mocker = mocker.patch.object(ProjectCommand, "_handle") | ||
ProjectCommand().run_from_argv( | ||
[*argv, *(["--all"] if all else [project.name for project in projects])] | ||
) | ||
handle_mocker.assert_has_calls([call(project) for project in projects], True) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"existing_projects", | ||
[ | ||
[], | ||
["foo"], | ||
["Foo"], | ||
["foo", "foobar"], | ||
], | ||
) | ||
@pytest.mark.parametrize("nonexistant_projects", [["bar"], ["bar", "baz"]]) | ||
def test_project_command( | ||
transactional_db, project_factory, capsys, nonexistant_projects, existing_projects | ||
): | ||
argv = ["", "project-command-test"] | ||
for project in existing_projects: | ||
project_factory(name=project) | ||
ProjectCommand().run_from_argv([*argv, *nonexistant_projects, *existing_projects]) | ||
_, stderr = capsys.readouterr() | ||
assert stderr == f"Projects with names {nonexistant_projects} do not exist\n" |
Large diffs are not rendered by default.
Oops, something went wrong.
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