-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/OWASP/Nest into feature
- Loading branch information
Showing
34 changed files
with
539 additions
and
309 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""GitHub repository GraphQL node.""" | ||
|
||
import graphene | ||
|
||
from apps.common.graphql.nodes import BaseNode | ||
from apps.github.models.repository import Repository | ||
|
||
|
||
class RepositoryNode(BaseNode): | ||
"""GitHub repository node.""" | ||
|
||
url = graphene.String() | ||
|
||
class Meta: | ||
model = Repository | ||
fields = ( | ||
"name", | ||
"forks_count", | ||
"stars_count", | ||
"open_issues_count", | ||
"subscribers_count", | ||
"contributors_count", | ||
) | ||
|
||
def resolve_url(self, info): | ||
"""Resolve URL.""" | ||
return self.url |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Test cases for RepositoryNode.""" | ||
|
||
from apps.common.graphql.nodes import BaseNode | ||
from apps.github.graphql.nodes.repository import RepositoryNode | ||
from apps.github.models.repository import Repository | ||
|
||
|
||
class TestRepositoryNode: | ||
"""Test cases for RepositoryNode class.""" | ||
|
||
def test_repository_node_inheritance(self): | ||
"""Test if RepositoryNode inherits from BaseNode.""" | ||
assert issubclass(RepositoryNode, BaseNode) | ||
|
||
def test_meta_configuration(self): | ||
"""Test if Meta is properly configured.""" | ||
assert RepositoryNode._meta.model == Repository | ||
expected_fields = { | ||
"contributors_count", | ||
"forks_count", | ||
"name", | ||
"open_issues_count", | ||
"stars_count", | ||
"subscribers_count", | ||
"url", | ||
} | ||
assert set(RepositoryNode._meta.fields) == expected_fields | ||
|
||
def test_resolve_url_field(self, mocker): | ||
"""Test if URL field is properly defined.""" | ||
field = RepositoryNode._meta.fields.get("url") | ||
assert field is not None | ||
assert str(field.type) == "String" |
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
Oops, something went wrong.