Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tests for importing taxonomies #225

Merged
merged 21 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ COPY parser /parser

USER off:off
COPY --chown=off:off ./backend/editor /code/editor
COPY --chown=off:off ./backend/sample /code/sample
RUN find /code/sample -type f -name '*.py' -exec chmod +x {} \;

CMD ["uvicorn", "editor.api:app", "--host", "0.0.0.0", "--port", "80"]
1 change: 0 additions & 1 deletion backend/editor/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ async def upload_taxonomy(
"""
Upload taxonomy file to be parsed
"""
# use the file name as the taxonomy name
taxonomy = TaxonomyGraph(branch, taxonomy_name)
if not taxonomy.is_valid_branch_name():
raise HTTPException(status_code=422, detail="branch_name: Enter a valid branch name!")
Expand Down
10 changes: 5 additions & 5 deletions backend/editor/entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .exceptions import GithubBranchExistsError # Custom exceptions
from .exceptions import (
GithubUploadError,
TaxnonomyImportError,
TaxonomyImportError,
TaxonomyParsingError,
TaxonomyUnparsingError,
)
Expand Down Expand Up @@ -124,7 +124,7 @@ async def import_from_github(self, description):

return status
except Exception as e:
raise TaxnonomyImportError() from e
raise TaxonomyImportError() from e

async def upload_taxonomy(self, filepath, description):
"""
Expand All @@ -136,7 +136,7 @@ async def upload_taxonomy(self, filepath, description):
await self.create_project(description)
return status
except Exception as e:
raise TaxnonomyImportError() from e
raise TaxonomyImportError() from e

def dump_taxonomy(self):
"""
Expand Down Expand Up @@ -614,11 +614,11 @@ async def delete_taxonomy_project(self, branch, taxonomy_name):
"""

delete_query = """
MATCH (n:PROJECT {taxonomy_name: $taxonomy_name, branch: $branch})
MATCH (n:PROJECT {taxonomy_name: $taxonomy_name, branch_name: $branch_name})
DELETE n
"""
result = await get_current_transaction().run(
delete_query, taxonomy_name=taxonomy_name, branch=branch
delete_query, taxonomy_name=taxonomy_name, branch_name=branch
)
summary = await result.consume()
count = summary.counters.nodes_deleted
Expand Down
2 changes: 1 addition & 1 deletion backend/editor/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):
return super().__init__(exception_message)


class TaxnonomyImportError(RuntimeError):
class TaxonomyImportError(RuntimeError):
"""
Raised when attempting to fetch a taxonomy from GitHub
"""
Expand Down
6 changes: 3 additions & 3 deletions backend/editor/github_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""
from textwrap import dedent

import github
from fastapi import HTTPException
from github import Github, GithubException

from . import settings

Expand Down Expand Up @@ -33,7 +33,7 @@ def init_driver_and_repo(self):
raise HTTPException(
status_code=400, detail="repo_uri is not set. Please add your access token in .env"
)
github_driver = Github(access_token)
github_driver = github.Github(access_token)
repo = github_driver.get_repo(repo_uri)
return repo

Expand Down Expand Up @@ -72,7 +72,7 @@ def update_file(self, filename):
current_file.sha,
branch=self.branch_name,
)
except GithubException as e:
except github.GithubException as e:
# Handle GitHub API-related exceptions
raise Exception(f"GitHub API error: {e}") from e
except FileNotFoundError as e:
Expand Down
Loading