mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
refactor: move remaining test examples to fixture files
This commit is contained in:
parent
4de8c25a3f
commit
642c1c50fb
4 changed files with 66 additions and 68 deletions
|
@ -281,35 +281,7 @@ class TestRepoMapTypescript(unittest.TestCase):
|
||||||
def test_get_repo_map_typescript(self):
|
def test_get_repo_map_typescript(self):
|
||||||
# Create a temporary directory with a sample TypeScript file
|
# Create a temporary directory with a sample TypeScript file
|
||||||
test_file_ts = "test_file.ts"
|
test_file_ts = "test_file.ts"
|
||||||
file_content_ts = """\
|
file_content_ts = ""
|
||||||
interface IMyInterface {
|
|
||||||
someMethod(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
type ExampleType = {
|
|
||||||
key: string;
|
|
||||||
value: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Status {
|
|
||||||
New,
|
|
||||||
InProgress,
|
|
||||||
Completed,
|
|
||||||
}
|
|
||||||
|
|
||||||
export class MyClass {
|
|
||||||
constructor(public value: number) {}
|
|
||||||
|
|
||||||
add(input: number): number {
|
|
||||||
return this.value + input;
|
|
||||||
return this.value + input;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function myFunction(input: number): number {
|
|
||||||
return input * 2;
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|
||||||
with IgnorantTemporaryDirectory() as temp_dir:
|
with IgnorantTemporaryDirectory() as temp_dir:
|
||||||
with open(os.path.join(temp_dir, test_file_ts), "w") as f:
|
with open(os.path.join(temp_dir, test_file_ts), "w") as f:
|
||||||
|
@ -335,19 +307,7 @@ export function myFunction(input: number): number {
|
||||||
def test_get_repo_map_tsx(self):
|
def test_get_repo_map_tsx(self):
|
||||||
# Create a temporary directory with a sample TSX file
|
# Create a temporary directory with a sample TSX file
|
||||||
test_file_tsx = "test_file.tsx"
|
test_file_tsx = "test_file.tsx"
|
||||||
file_content_tsx = """\
|
file_content_tsx = ""
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
interface GreetingProps {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Greeting: React.FC<GreetingProps> = ({ name }) => {
|
|
||||||
return <h1>Hello, {name}!</h1>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Greeting;
|
|
||||||
"""
|
|
||||||
|
|
||||||
with IgnorantTemporaryDirectory() as temp_dir:
|
with IgnorantTemporaryDirectory() as temp_dir:
|
||||||
with open(os.path.join(temp_dir, test_file_tsx), "w") as f:
|
with open(os.path.join(temp_dir, test_file_tsx), "w") as f:
|
||||||
|
@ -480,32 +440,7 @@ let () =
|
||||||
),
|
),
|
||||||
"python": (
|
"python": (
|
||||||
"test.py",
|
"test.py",
|
||||||
'''from typing import Optional, List
|
"", # Now reads from fixture file
|
||||||
|
|
||||||
class Person:
|
|
||||||
"""A class representing a person."""
|
|
||||||
|
|
||||||
def __init__(self, name: str, age: Optional[int] = None):
|
|
||||||
self.name = name
|
|
||||||
self.age = age
|
|
||||||
|
|
||||||
def greet(self, formal: bool = False) -> str:
|
|
||||||
"""Generate a greeting."""
|
|
||||||
prefix = "Good day" if formal else "Hello"
|
|
||||||
return f"{prefix}, {self.name}!"
|
|
||||||
|
|
||||||
def create_greeting_list(people: List[Person]) -> List[str]:
|
|
||||||
"""Create greetings for a list of people."""
|
|
||||||
return [person.greet() for person in people]
|
|
||||||
|
|
||||||
# Constants
|
|
||||||
DEFAULT_NAME = "World"
|
|
||||||
MAX_AGE = 150
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
person = Person(DEFAULT_NAME)
|
|
||||||
print(person.greet())
|
|
||||||
''',
|
|
||||||
"Person", # Key symbol to check
|
"Person", # Key symbol to check
|
||||||
),
|
),
|
||||||
"ql": (
|
"ql": (
|
||||||
|
|
25
tests/fixtures/languages/python/test.py
vendored
Normal file
25
tests/fixtures/languages/python/test.py
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
from typing import Optional, List
|
||||||
|
|
||||||
|
class Person:
|
||||||
|
"""A class representing a person."""
|
||||||
|
|
||||||
|
def __init__(self, name: str, age: Optional[int] = None):
|
||||||
|
self.name = name
|
||||||
|
self.age = age
|
||||||
|
|
||||||
|
def greet(self, formal: bool = False) -> str:
|
||||||
|
"""Generate a greeting."""
|
||||||
|
prefix = "Good day" if formal else "Hello"
|
||||||
|
return f"{prefix}, {self.name}!"
|
||||||
|
|
||||||
|
def create_greeting_list(people: List[Person]) -> List[str]:
|
||||||
|
"""Create greetings for a list of people."""
|
||||||
|
return [person.greet() for person in people]
|
||||||
|
|
||||||
|
# Constants
|
||||||
|
DEFAULT_NAME = "World"
|
||||||
|
MAX_AGE = 150
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
person = Person(DEFAULT_NAME)
|
||||||
|
print(person.greet())
|
11
tests/fixtures/languages/tsx/test.tsx
vendored
Normal file
11
tests/fixtures/languages/tsx/test.tsx
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface GreetingProps {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Greeting: React.FC<GreetingProps> = ({ name }) => {
|
||||||
|
return <h1>Hello, {name}!</h1>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Greeting;
|
27
tests/fixtures/languages/typescript/test.ts
vendored
Normal file
27
tests/fixtures/languages/typescript/test.ts
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
interface IMyInterface {
|
||||||
|
someMethod(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExampleType = {
|
||||||
|
key: string;
|
||||||
|
value: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Status {
|
||||||
|
New,
|
||||||
|
InProgress,
|
||||||
|
Completed,
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MyClass {
|
||||||
|
constructor(public value: number) {}
|
||||||
|
|
||||||
|
add(input: number): number {
|
||||||
|
return this.value + input;
|
||||||
|
return this.value + input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function myFunction(input: number): number {
|
||||||
|
return input * 2;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue