Skip to content

Commit

Permalink
Test schema, add min length to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed May 22, 2024
1 parent 456fe2f commit 08f2da1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
17 changes: 11 additions & 6 deletions aws_project_costs/project-cost-schema.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"$schema": "http://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/hic-infra/TODO",
"$id": "https://github.com/hic-infra/hic-aws-project-cost",
"title": "AWS project cost configuration",
"type": "object",
"properties": {
"proj-tag-names": {
"description": "A mapping of AWS project tags to the canonical project name",
"type": "object",
"additionalProperties": {
"type": "string"
"type": "string",
"minLength": 1
}
},
"project-groups": {
Expand All @@ -17,7 +18,8 @@
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
"type": "string",
"minLength": 1
}
}
},
Expand All @@ -29,7 +31,8 @@
"properties": {
"name": {
"description": "Name of the AWS account",
"type": "string"
"type": "string",
"minLength": 1
},
"billing-type": {
"description": "Whether costs should be split across multiple projects or assigned to a single project",
Expand All @@ -45,12 +48,14 @@
"type": "array",
"minItems": 1,
"items": {
"type": "string"
"type": "string",
"minLength": 1
}
},
"project": {
"description": "The project responsible for all costs, required for billing-type=project-specific",
"type": "string"
"type": "string",
"minLength": 1
}
},
"required": ["name", "billing-type"],
Expand Down
11 changes: 9 additions & 2 deletions tests/test_project_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
import yaml

from aws_project_costs.project_costs import analyse_costs_csv

# from aws_project_costs.schema import validate
from aws_project_costs.schema import validate

EXAMPLE_DIR = Path(__file__).parent / ".." / "example"


def test_schema_validate():
config_yaml = EXAMPLE_DIR / "projects.yaml"
with (config_yaml).open() as f:
cfg = yaml.safe_load(f)
errors = validate(cfg, raise_on_error=False)
assert len(errors) == 0


def test_analyse_costs_csv(tmp_path):
config_yaml = EXAMPLE_DIR / "projects.yaml"
input_csv = EXAMPLE_DIR / "2024-01-01_2024-02-01.csv"
Expand Down

0 comments on commit 08f2da1

Please sign in to comment.