mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 11:50:37 +08:00
keys fallback
This commit is contained in:
@ -42,3 +42,49 @@ age: 35
|
||||
def test_empty_yaml_fixed(self):
|
||||
review_text = ""
|
||||
assert try_fix_yaml(review_text) is None
|
||||
|
||||
|
||||
# The function extracts YAML snippet
|
||||
def test_no_initial_yaml(self):
|
||||
review_text = '''\
|
||||
I suggest the following:
|
||||
|
||||
code_suggestions:
|
||||
- relevant_file: |
|
||||
src/index.ts
|
||||
label: |
|
||||
best practice
|
||||
|
||||
- relevant_file: |
|
||||
src/index2.ts
|
||||
label: |
|
||||
enhancment
|
||||
```
|
||||
|
||||
We can further improve the code by using the `const` keyword instead of `var` in the `src/index.ts` file.
|
||||
'''
|
||||
expected_output = {'code_suggestions': [{'relevant_file': 'src/index.ts\n', 'label': 'best practice\n'}, {'relevant_file': 'src/index2.ts\n', 'label': 'enhancment'}]}
|
||||
|
||||
assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='label') == expected_output
|
||||
|
||||
def test_with_initial_yaml(self):
|
||||
review_text = '''\
|
||||
I suggest the following:
|
||||
|
||||
```
|
||||
code_suggestions:
|
||||
- relevant_file: |
|
||||
src/index.ts
|
||||
label: |
|
||||
best practice
|
||||
|
||||
- relevant_file: |
|
||||
src/index2.ts
|
||||
label: |
|
||||
enhancment
|
||||
```
|
||||
|
||||
We can further improve the code by using the `const` keyword instead of `var` in the `src/index.ts` file.
|
||||
'''
|
||||
expected_output = {'code_suggestions': [{'relevant_file': 'src/index.ts\n', 'label': 'best practice\n'}, {'relevant_file': 'src/index2.ts\n', 'label': 'enhancment'}]}
|
||||
assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='label') == expected_output
|
Reference in New Issue
Block a user