Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Oct 26, 2022
1 parent 09524ab commit e1d0c14
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from aiopg.sa import SAConnection
from simcore_postgres_database.models.projects import projects as projects_table
from simcore_postgres_database.utils_aiopg_orm import BaseOrm

from ..db_base_repository import BaseRepository


class ProjectsRepository(BaseRepository):

# TOOL
class ProjectsOrm(BaseOrm[str]):
def __init__(self, connection: SAConnection):
super().__init__(
projects_table,
connection,
readonly={"id", "creation_date", "last_change_date"},
writeonce={"uuid"},
)

async def get_all(self):
pass

async def get_one(self):
pass

async def create(self):
pass

async def update(self):
pass

async def delete_all(self):
pass

async def delete_one(self):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging

from aiohttp import web
from models_library.projects import ProjectID
from models_library.projects_state import ProjectState
from pydantic import BaseModel, Extra, Field
from servicelib.aiohttp.requests_validation import (
Expand Down Expand Up @@ -40,8 +41,8 @@

class _ProjectCloneParams(BaseModel):
# override some attributes: force_type,
as_template: False = Field(
None,
as_template: bool = Field(
False,
description="Whether the clone is set as template",
)
copy_data: bool = Field(
Expand Down Expand Up @@ -79,7 +80,7 @@ async def clone_project(request: web.Request) -> web.Response:

# This is a new project and every new graph needs to be reflected in the pipeline tables
await director_v2_api.create_or_update_pipeline(
request.app, req_ctx.user_id, cloned_project.uuid
request.app, req_ctx.user_id, ProjectID(cloned_project["uuid"])
)

# Appends state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@


@pytest.mark.parametrize("api_call", (NEW_PROJECT,))
def test_new_project_models(api_call: HttpApiCallCapture):
model = ProjectCreate.parse_obj(api_call.request_payload)
async def test_new_project_models(api_call: HttpApiCallCapture):
create_schema = ProjectCreate.parse_obj(api_call.request_payload)

# prune and get into ProjectSQLModel
ProjectSQLModel.from_orm(create_schema)

db_model = self.db_model(**model.dict())

assert api_call.response_body
model = ProjectGet.parse_obj(api_call.response_body["data"])
get_schema = ProjectGet.parse_obj(api_call.response_body["data"])


@pytest.mark.parametrize("api_call", (GET_PROJECT,))
Expand Down Expand Up @@ -114,8 +119,8 @@ def test_build_project_model(faker: Faker):


def test_create_workbench(faker: Faker):
"""DEV: some tools to build pipelines"""

# some tools to build pipelines
def create_sleeper(
label, *, input_1: Optional[str] = None, input_2: int = 2, input_3: bool = False
):
Expand Down

0 comments on commit e1d0c14

Please sign in to comment.