testing adjustments

This commit is contained in:
2025-07-30 21:34:55 -04:00
parent 2971858b37
commit 19362ddeb3
5 changed files with 122 additions and 42 deletions

View File

@@ -31,7 +31,7 @@ class BaseEndpoint:
params: Optional[Dict[str, Any]] = None,
json_data: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> Dict[str, Any]:
) -> Any:
"""Make HTTP request through the client.
Args:
@@ -54,7 +54,7 @@ class BaseEndpoint:
def _get(
self, endpoint: str, params: Optional[Dict[str, Any]] = None, **kwargs: Any
) -> Dict[str, Any]:
) -> Any:
"""Make GET request.
Args:
@@ -73,7 +73,7 @@ class BaseEndpoint:
json_data: Optional[Dict[str, Any]] = None,
params: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> Dict[str, Any]:
) -> Any:
"""Make POST request.
Args:
@@ -95,7 +95,7 @@ class BaseEndpoint:
json_data: Optional[Dict[str, Any]] = None,
params: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> Dict[str, Any]:
) -> Any:
"""Make PUT request.
Args:
@@ -113,7 +113,7 @@ class BaseEndpoint:
def _delete(
self, endpoint: str, params: Optional[Dict[str, Any]] = None, **kwargs: Any
) -> Dict[str, Any]:
) -> Any:
"""Make DELETE request.
Args:

View File

@@ -84,15 +84,24 @@ class PagesEndpoint(BaseEndpoint):
if order_direction not in ["ASC", "DESC"]:
raise ValidationError("order_direction must be ASC or DESC")
# Build GraphQL query using actual Wiki.js schema
# Build GraphQL query with variables using actual Wiki.js schema
query = """
query {
query($limit: Int, $offset: Int, $search: String, $tags: [String], $locale: String, $authorId: Int, $orderBy: String, $orderDirection: String) {
pages {
list {
list(limit: $limit, offset: $offset, search: $search, tags: $tags, locale: $locale, authorId: $authorId, orderBy: $orderBy, orderDirection: $orderDirection) {
id
title
path
content
description
isPublished
isPrivate
tags
locale
authorId
authorName
authorEmail
editor
createdAt
updatedAt
}
@@ -100,8 +109,31 @@ class PagesEndpoint(BaseEndpoint):
}
"""
# Make request (no variables needed for simple list query)
response = self._post("/graphql", json_data={"query": query})
# Build variables object
variables = {}
if limit is not None:
variables["limit"] = limit
if offset is not None:
variables["offset"] = offset
if search is not None:
variables["search"] = search
if tags is not None:
variables["tags"] = tags
if locale is not None:
variables["locale"] = locale
if author_id is not None:
variables["authorId"] = author_id
if order_by is not None:
variables["orderBy"] = order_by
if order_direction is not None:
variables["orderDirection"] = order_direction
# Make request with query and variables
json_data = {"query": query}
if variables:
json_data["variables"] = variables
response = self._post("/graphql", json_data=json_data)
# Parse response
if "errors" in response:
@@ -277,9 +309,29 @@ class PagesEndpoint(BaseEndpoint):
# Build GraphQL mutation using actual Wiki.js schema
mutation = """
mutation($content: String!, $description: String!, $editor: String!, $isPublished: Boolean!, $isPrivate: Boolean!, $locale: String!, $path: String!, $tags: [String]!, $title: String!) {
mutation(
$content: String!,
$description: String!,
$editor: String!,
$isPublished: Boolean!,
$isPrivate: Boolean!,
$locale: String!,
$path: String!,
$tags: [String]!,
$title: String!
) {
pages {
create(content: $content, description: $description, editor: $editor, isPublished: $isPublished, isPrivate: $isPrivate, locale: $locale, path: $path, tags: $tags, title: $title) {
create(
content: $content,
description: $description,
editor: $editor,
isPublished: $isPublished,
isPrivate: $isPrivate,
locale: $locale,
path: $path,
tags: $tags,
title: $title
) {
responseResult {
succeeded
errorCode
@@ -381,7 +433,15 @@ class PagesEndpoint(BaseEndpoint):
# Build GraphQL mutation
mutation = """
mutation($id: Int!, $title: String, $content: String, $description: String, $isPublished: Boolean, $isPrivate: Boolean, $tags: [String]) {
mutation(
$id: Int!,
$title: String,
$content: String,
$description: String,
$isPublished: Boolean,
$isPrivate: Boolean,
$tags: [String]
) {
updatePage(
id: $id,
title: $title,
@@ -602,7 +662,7 @@ class PagesEndpoint(BaseEndpoint):
# Handle tags - convert from Wiki.js format
if "tags" in page_data:
if isinstance(page_data["tags"], list):
# Handle both formats: ["tag1", "tag2"] or [{"tag": "tag1"}, {"tag": "tag2"}]
# Handle both formats: ["tag1", "tag2"] or [{"tag": "tag1"}]
tags = []
for tag in page_data["tags"]:
if isinstance(tag, dict) and "tag" in tag: