Conversation
a46a2c3 to
3309512
Compare
|
This is example prompt. What I want to doI want to test the creation of encrypted and decrypted images in Harvester. Please help me:
Shared FixturesPlease reuse or define the following shared fixtures:
Main Test CasesPlease separate the following into individual test functions within the same class:
Additional Notes
|
3309512 to
faef991
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new documentation file for GitHub Copilot instructions to streamline test case generation. The changes include:
- Detailed guidelines for writing integration and API tests.
- Templates for shared fixtures, test cases, and Harvester API manager implementations.
Comments suppressed due to low confidence (2)
.github/instructions/copilot-instructions.md:45
- The fixture scope 'module or class' is ambiguous as pytest expects a single valid scope (e.g. 'module' or 'class'). Please clarify this or split into separate examples.
@pytest.fixture(scope="module or class")
.github/instructions/copilot-instructions.md:77
- [nitpick] The placeholder '${some fixtures and shared_fixture}' may confuse users. Consider replacing it with a clear indication of the required fixture names.
def test_xxxx(self, ${some fixtures and shared_fixture}):
faef991 to
3b8f856
Compare
lanfon72
left a comment
There was a problem hiding this comment.
Harvester API would be more complicated, so I feel copilot would not be useful in it.
| assert code == xxxx, f"Expected status code xxxx, got {code} with data: {data}" | ||
| ``` | ||
|
|
||
| ## Harvester API Manager Template |
There was a problem hiding this comment.
Harvester API is not tight with our pytest test cases, we would separate it to another repo in near future, so this would not be used in here.
There was a problem hiding this comment.
If so, I think we can keep it here until we move it out.
| ## Don't Do | ||
|
|
||
| - Do **not** use method names with `_` prefixes in tests, such as `api_client.[resource]._[method]`. | ||
| - Do **not** define a function inside another function, for example: |
There was a problem hiding this comment.
for example as
tests/harvester_e2e_tests/fixtures/virtualmachines.py
Lines 119 to 368 in 71d70d9
so it would not be Don't, but need more consideration.
There was a problem hiding this comment.
Okay. I didn't notice we have this pattern, thanks!
976980a to
e81c9bc
Compare
Signed-off-by: Jack Yu <jack.yu@suse.com>
e81c9bc to
3aca361
Compare
Which issue(s) this PR fixes:
Issue harvester/harvester#8148
What this PR does / why we need it:
Since we can use copilot, I think we can utilize it.
It's just a way to create the test cases quickly, it still require us to adjust. It's not a magic tool right now, we still need to improve the prompt and copilot instruction. At least, I used it to create another integration test PR (#2054).
Special notes for your reviewer:
Before trying this, please add below codes in your
settings.jsonof VSCode.{ "github.copilot.chat.codeGeneration.useInstructionFiles": true, "github.copilot.chat.codeGeneration.instructions": [ { "file": "./.github/instructions/harvester-test-instructions.md", "description": "Instructions for generating integration/api test cases for the Harvester server", } ], }Additional documentation or context
Copilot Instruction