-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organization and Project CRUD tests (#1467)
* Organization and Project CRUD tests * Nits
- Loading branch information
Showing
4 changed files
with
146 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
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,63 @@ | ||
import pytest | ||
|
||
|
||
def test_get_organization(session, organization): | ||
from dispatch.organization.service import get | ||
|
||
t_organization = get(db_session=session, organization_id=organization.id) | ||
assert t_organization.id == organization.id | ||
|
||
|
||
def test_get_all(session, organizations): | ||
from dispatch.organization.service import get_all | ||
|
||
t_organizations = get_all(db_session=session).all() | ||
assert len(t_organizations) > 1 | ||
|
||
|
||
def test_create(session): | ||
from dispatch.organization.service import create | ||
from dispatch.organization.models import OrganizationCreate | ||
|
||
name = "name" | ||
description = "description" | ||
default = True | ||
banner_enabled = True | ||
banner_color = "red" | ||
banner_text = "banner" | ||
|
||
organization_in = OrganizationCreate( | ||
name=name, | ||
description=description, | ||
default=default, | ||
banner_enabled=banner_enabled, | ||
banner_color=banner_color, | ||
banner_text=banner_text, | ||
) | ||
organization = create(db_session=session, organization_in=organization_in) | ||
assert organization | ||
|
||
|
||
@pytest.mark.skip | ||
def test_update(session, organization): | ||
from dispatch.organization.service import update | ||
from dispatch.organization.models import OrganizationUpdate | ||
|
||
name = "Updated name" | ||
|
||
organization_in = OrganizationUpdate( | ||
name=name, | ||
) | ||
organization = update( | ||
db_session=session, | ||
organization=organization, | ||
organization_in=organization_in, | ||
) | ||
assert organization.name == name | ||
|
||
|
||
def test_delete(session, organization): | ||
from dispatch.organization.service import delete, get | ||
|
||
delete(db_session=session, organization_id=organization.id) | ||
assert not get(db_session=session, organization_id=organization.id) |
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,60 @@ | ||
import pytest | ||
|
||
|
||
def test_get_project(session, project): | ||
from dispatch.project.service import get | ||
|
||
t_project = get(db_session=session, project_id=project.id) | ||
assert t_project.id == project.id | ||
|
||
|
||
def test_get_all(session, projects): | ||
from dispatch.project.service import get_all | ||
|
||
t_projects = get_all(db_session=session).all() | ||
assert len(t_projects) > 1 | ||
|
||
|
||
def test_create(session, organization): | ||
from dispatch.project.service import create | ||
from dispatch.project.models import ProjectCreate | ||
|
||
name = "name" | ||
description = "description" | ||
default = True | ||
color = "red" | ||
|
||
project_in = ProjectCreate( | ||
name=name, | ||
description=description, | ||
default=default, | ||
color=color, | ||
organization=organization, | ||
) | ||
project = create(db_session=session, project_in=project_in) | ||
assert project | ||
|
||
|
||
@pytest.mark.skip | ||
def test_update(session, project): | ||
from dispatch.project.service import update | ||
from dispatch.project.models import ProjectUpdate | ||
|
||
name = "Updated name" | ||
|
||
project_in = ProjectUpdate( | ||
name=name, | ||
) | ||
project = update( | ||
db_session=session, | ||
project=project, | ||
project_in=project_in, | ||
) | ||
assert project.name == name | ||
|
||
|
||
def test_delete(session, project): | ||
from dispatch.project.service import delete, get | ||
|
||
delete(db_session=session, project_id=project.id) | ||
assert not get(db_session=session, project_id=project.id) |