Skip to content

Commit

Permalink
Upload to S3
Browse files Browse the repository at this point in the history
  • Loading branch information
fivegrant committed Sep 11, 2023
1 parent 906a932 commit 7bc4d34
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 13 deletions.
5 changes: 4 additions & 1 deletion env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ MIT_TR_URL=http://mit-tr.staging.terarium.ai
LOG_LEVEL=INFO
MOCK_TA1=True
MOCK_TDSt=True
OPENAI_API_KEY=foo
OPENAI_API_KEY=foo
AWS_ACCESS_KEY_ID=NA
AWS_SECRET_ACCESS_KEY=NA
BUCKET=NA
3 changes: 3 additions & 0 deletions lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Settings(BaseSettings):
TDS_URL: str = "http://tds:15"
OPENAI_API_KEY: str = "foo"
LOG_LEVEL: str = "INFO"
AWS_ACCESS_KEY_ID: str = "NA"
AWS_SECRET_ACCESS_KEY: str = "NA"
BUCKET: str = "NA"


settings = Settings()
83 changes: 74 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pydantic-settings = "^2.0.3"
uvicorn = "^0.22.0"
fastapi = "^0.100.0"
pypdf = "^3.12.0"
boto3 = "^1.28.44"

[tool.poetry.group.dev.dependencies]
service-test-tools = {git = "https://github.com/jataware/service-test-tools"}
Expand All @@ -35,7 +36,9 @@ gen-report = "tests.report:report"
[tool.poe.tasks]
_test = "status-test"
_report = "gen-report"
report = ["_test", "_report"]
report.sequence = ["_test", "_report"]
report.ignore_fail = true


[tool.pytest.ini_options]
markers = ["resource"]
Expand Down
12 changes: 10 additions & 2 deletions tests/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import yaml
import pytest
import boto3

from lib.settings import settings

def test(output_file="tests/output/tests.json"):
pytest.main(["--json-report", f"--json-report-file={output_file}"])
Expand Down Expand Up @@ -47,9 +50,14 @@ def add_case(testobj):
report[scenario]["description"] = spec["description"]

timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
filename = f"tests/output/report_{timestamp}.json"
with open(filename, "w") as file:
filename = f"report_{timestamp}.json"
fullpath = os.path.join("tests/output", "filename")
with open(fullpath, "w") as file:
json.dump(report, file, indent=2)

s3 = boto3.client("s3")
full_handle = os.path.join("ta1", filename)
s3.upload_file(fullpath, settings.BUCKET, full_handle)

if __name__ == "__main__":
report()

0 comments on commit 7bc4d34

Please sign in to comment.