-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates in tests and making them modular
- Loading branch information
1 parent
054d6aa
commit 70d0d16
Showing
6 changed files
with
92 additions
and
69 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 |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import pytest | ||
|
||
from apps.github.models.organization import Organization | ||
|
||
|
||
class TestOrganizationIndexMixin: | ||
def test_organization_index(self): | ||
@pytest.mark.parametrize( | ||
("attr", "expected"), | ||
[ | ||
("idx_name", "Organization Name login"), | ||
("idx_company", "Company Location"), | ||
], | ||
) | ||
def test_organization_index(self, attr, expected): | ||
organization = Organization( | ||
name="Organization Name", login="login", company="Company", location="Location" | ||
) | ||
|
||
assert organization.idx_name == "Organization Name login" | ||
assert organization.idx_company == "Company Location" | ||
assert getattr(organization, attr) == expected |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import pytest | ||
|
||
from apps.github.models.mixins.user import UserIndexMixin | ||
|
||
FOLLOWERS_COUNT = 5 | ||
|
@@ -6,7 +8,26 @@ | |
|
||
|
||
class TestUserIndexMixin: | ||
def test_user_index(self): | ||
@pytest.mark.parametrize( | ||
("attr", "expected"), | ||
[ | ||
("idx_avatar_url", "https://avatars.githubusercontent.com/u/1"), | ||
("idx_bio", "Bio"), | ||
("idx_company", "Company"), | ||
("idx_created_at", "2021-01-01T00:00:00Z"), | ||
("idx_email", "[email protected]"), | ||
("idx_followers_count", FOLLOWERS_COUNT), | ||
("idx_following_count", FOLLOWING_COUNT), | ||
("idx_location", "Earth"), | ||
("idx_key", "user_login"), | ||
("idx_name", "John Doe"), | ||
("idx_public_repositories_count", REPOSITORIES_COUNT), | ||
("idx_title", "GitHub User"), | ||
("idx_updated_at", "2021-12-31T23:59:59Z"), | ||
("idx_url", "https://api.github.com/users/user_login"), | ||
], | ||
) | ||
def test_user_index(self, attr, expected): | ||
class MockModel(UserIndexMixin): | ||
def __init__(self): | ||
self.avatar_url = "https://avatars.githubusercontent.com/u/1" | ||
|
@@ -26,19 +47,4 @@ def __init__(self): | |
|
||
mock_instance = MockModel() | ||
|
||
assert isinstance(mock_instance, UserIndexMixin) | ||
|
||
assert mock_instance.idx_avatar_url == "https://avatars.githubusercontent.com/u/1" | ||
assert mock_instance.idx_bio == "Bio" | ||
assert mock_instance.idx_company == "Company" | ||
assert mock_instance.idx_created_at == "2021-01-01T00:00:00Z" | ||
assert mock_instance.idx_email == "[email protected]" | ||
assert mock_instance.idx_followers_count == FOLLOWERS_COUNT | ||
assert mock_instance.idx_following_count == FOLLOWING_COUNT | ||
assert mock_instance.idx_location == "Earth" | ||
assert mock_instance.idx_key == "user_login" | ||
assert mock_instance.idx_name == "John Doe" | ||
assert mock_instance.idx_public_repositories_count == REPOSITORIES_COUNT | ||
assert mock_instance.idx_title == "GitHub User" | ||
assert mock_instance.idx_updated_at == "2021-12-31T23:59:59Z" | ||
assert mock_instance.idx_url == "https://api.github.com/users/user_login" | ||
assert getattr(mock_instance, attr) == expected |
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