Skip to content

Commit

Permalink
Fixed subfolder tests. Resolves #93
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinXPN authored Jan 26, 2024
1 parent 462e064 commit 5b31238
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ pre-commit run --all-files # Tidy-up the
sam build --use-container # Builds the project
sam local start-lambda --env-vars .env.json # Start all the functions locally
# In another terminal tab run the following
cd tests # Change the current directory to tests
pytest --cov=sync --cov=coderunners --cov=bouncer --cov-report term-missing
pytest tests --cov=sync --cov=coderunners --cov=bouncer --cov-report term-missing
```

### Project structure
Expand Down
19 changes: 9 additions & 10 deletions tests/integration/coderunners/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_no_file(self):
res = CodeRunner.from_language(language=request.language).invoke(lambda_client, request=request)
print(res)
assert res.overall.status == Status.WA
assert len(res.test_results) == 4
assert len(res.test_results) == 5
assert res.test_results[0].status == Status.OK
assert res.test_results[1].status == Status.WA
assert res.test_results[2].status == Status.WA
Expand All @@ -41,22 +41,21 @@ def test_no_file(self):
def test_with_file(self):
request = SubmissionRequest(test_cases=self.test_cases, stop_on_first_fail=False, language='python', code={
'main.py': dedent('''
import os
from pathlib import Path
n = int(input())
print(n + 1)
with open('res.txt', 'w') as f:
f.write('heyhey')
with open('subfolder/hey.txt', 'w') as f:
f.write('hello hello')
0 with open('subfolder/subsubfolder/res.txt', 'w') as f:
f.write('Result!!!')
Path('res.txt').write_text('heyhey')
# Create a subfolder and subsubfolder and write to the corresponding files
Path('subfolder/subsubfolder').mkdir(parents=True, exist_ok=True)
Path('subfolder/hey.txt').write_text('hello hello')
Path('subfolder/subsubfolder/res.txt').write_text('Result!!!')
# print(os.getcwd())
'''),
}, return_outputs=True)
res = CodeRunner.from_language(language=request.language).invoke(lambda_client, request=request)
print(res)
assert res.overall.status == Status.WA
assert len(res.test_results) == 4
assert len(res.test_results) == 5
assert res.test_results[0].status == Status.OK
assert res.test_results[1].status == Status.WA
assert res.test_results[2].status == Status.OK
Expand All @@ -77,7 +76,7 @@ def test_with_assets(self):
res = CodeRunner.from_language(language=request.language).invoke(lambda_client, request=request)
print(res)
assert res.overall.status == Status.WA
assert len(res.test_results) == 4
assert len(res.test_results) == 5
assert res.test_results[0].status == Status.OK
assert res.test_results[1].status == Status.WA
assert res.test_results[2].status == Status.OK
Expand Down

0 comments on commit 5b31238

Please sign in to comment.