Skip to content

Commit

Permalink
Merge pull request #864 from docat-org/feat/project-ordering
Browse files Browse the repository at this point in the history
Feat: Sort Projects Alphabetically
  • Loading branch information
reglim authored Apr 30, 2024
2 parents 6604d61 + 8f48548 commit 675d132
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docat/docat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_all_projects(upload_folder_path: Path, include_hidden: bool) -> Projects
"""
projects: list[Project] = []

for project in upload_folder_path.iterdir():
for project in sorted(upload_folder_path.iterdir()):
if not project.is_dir():
continue

Expand Down
13 changes: 10 additions & 3 deletions docat/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@


def test_project_api(temp_project_version):
project = "project"
docs = temp_project_version(project, "1.0")
docs = temp_project_version("project", "1.0")
docs = temp_project_version("different-project", "1.0")

with patch("docat.app.DOCAT_UPLOAD_FOLDER", docs):
response = client.get("/api/projects")

assert response.status_code == httpx.codes.OK
assert response.json() == {
"projects": [
{
"name": "different-project",
"logo": False,
"versions": [
{"name": "1.0", "tags": ["latest"], "hidden": False},
],
},
{
"name": "project",
"logo": False,
"versions": [
{"name": "1.0", "tags": ["latest"], "hidden": False},
],
}
},
]
}

Expand Down

0 comments on commit 675d132

Please sign in to comment.