Conversation
…ure/114-poc-of-testcase-documentation
… tests ie. `Log ${app_url}` instead of only `Log`
@MaciejWiczk The main idea there, was that we only add/delete suites as suite hierarchies, not individual suites. That means that endpoint should expect a full suite hierarchy, which is a tree of nested suites, with the tree root being top-level suite, not a part of other suite. It simplifies creation of individual suites and relations between them so that we have easy read access to them and can treat them as regular resource then. Once the suites are saved and you have the IDs returned, adding test cases is straightforward because each test case is linked with specific suite. |
Codecov Report
@@ Coverage Diff @@
## master #449 +/- ##
==========================================
- Coverage 96.24% 95.63% -0.62%
==========================================
Files 46 47 +1
Lines 1385 1419 +34
==========================================
+ Hits 1333 1357 +24
- Misses 52 62 +10
Continue to review full report at Codecov.
|
| raise HTTPException(status_code=400, detail="Suite does not exist") | ||
| try: | ||
| db_test_case: DBTestCase = repository.add(DBTestCase.create(test_case)) | ||
| return repository.get(db_test_case.id) |
There was a problem hiding this comment.
This is wrong, and I know I'm missing something. @pbylicki could You take a look?
There was a problem hiding this comment.
Can you tell what is the error you're facing? I don't see any unit tests for that yet and just by looking at this code it seems to be doing the right thing (map payload to db model -> create record and return it with id -> get full record including suite data by that id)
|
|
||
| @router.get("/{id}/", response_model=Suite) | ||
| def get_suite(*, repository: SuiteRepository = Depends(get_suite_repository), id: int): | ||
| suite: Optional[DBSuite] = repository.get(id) |
There was a problem hiding this comment.
this is not DBSuite, repository already maps it to response model
| def get_test_case( | ||
| *, repository: TestCaseRepository = Depends(get_test_case_repository), id: int | ||
| ): | ||
| testcase: Optional[DBTestCase] = repository.get(id) |
There was a problem hiding this comment.
this is not DBTestCase, repository already maps it to response model
| suite_repository: SuiteRepository = Depends(get_suite_repository), | ||
| test_case: TestCaseCreate, | ||
| ): | ||
| suite: Optional[DBSuite] = suite_repository.get(test_case.suite_id) |
There was a problem hiding this comment.
this is not DBSuite, repository already maps it to response model
| repository: SuiteRepository = Depends(get_suite_repository), | ||
| ): | ||
| deleted: int = repository.delete_all_hierarchies() | ||
| if deleted: |
There was a problem hiding this comment.
IMO these delete all endpoints for suites and test cases should return response including number of deleted records, like we do for Keyword Statistics (and also skip the case of returning 404 for 0 rows found).
I know that we have it implemented like this for Collections and I missed it before, but I think my proposal gives more meaningful output that can be also included in CLI logs for visibility.
| @@ -0,0 +1,8 @@ | |||
| from robot.testdoc import TestSuiteFactory | |||
|
|
||
|
|
||
| @router.delete("/") | ||
| def delete_all_test_cases( |
There was a problem hiding this comment.
is this endpoint needed? When you delete the suites (and I see it is used in CLI), it also deletes related test cases.
@pbylicki I'm trying to figure out how to add suites with testcases, but I would need your help on that. I did some WIP code in this PR, but I'm missing logic on hierarchies etc. Could You navigate me?