Skip to content

Commit

Permalink
Merge pull request #56 from alan-turing-institute/feature/react-tests
Browse files Browse the repository at this point in the history
Feature/react tests
  • Loading branch information
nbarlowATI committed Mar 16, 2022
2 parents 19628bb + 7351be3 commit c0286f1
Show file tree
Hide file tree
Showing 44 changed files with 918 additions and 1,373 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-tests.yaml
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8' ]
python-version: ["3.7", "3.8"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/frontend-style.yaml
Expand Up @@ -10,6 +10,6 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
node-version: "16"
- run: npm install
- run: npx prettier --check .
21 changes: 21 additions & 0 deletions .github/workflows/frontend-tests.yaml
@@ -0,0 +1,21 @@
name: frontend-tests
on: [push, pull_request, workflow_dispatch]
defaults:
run:
working-directory: ./frontend
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: npm i
- name: npm test
run: npm test
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -72,7 +72,7 @@ db.sqlite3-journal
instance/
.webassets-cache

# Visual studio stuff:
# Visual studio stuff:
.vscode/

# Scrapy stuff:
Expand Down
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
language: python
files: ^eap_backend/
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.0
hooks:
- id: prettier
files: ^frontend/src/
args: [--write]
2 changes: 1 addition & 1 deletion eap_backend/Dockerfile
Expand Up @@ -7,4 +7,4 @@ ENV DBNAME=MY_DB_DATABASE_NAME
ENV DBUSER=MY_DB_USERNAME
ENV DBPASSWORD=MY_DB_PASSWORD
RUN python manage.py migrate
ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8000"]
ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8000"]
66 changes: 33 additions & 33 deletions eap_backend/eap_api/API_docs.md
@@ -1,132 +1,132 @@
## API for the Assurance Platform backend

The API endpoints in this document should be appended to a BASE_URL, which will depend on where you deploy the app.
If you are developing/running locally, BASE_URL will be `http://localhost:8000/api`.
If you are developing/running locally, BASE_URL will be `http://localhost:8000/api`.
If you deploy to e.g. Azure, it will be something like `https://<your-azure-app-name>.azurewebsites.net/api`.

### `/cases/`
* A GET request will list the available AssuranceCases:
* A GET request will list the available AssuranceCases:
- returns `[{name: <str:case_name>, id: <int:case_id>}, ...]`
* A POST request will create a new AssuranceCase.
* A POST request will create a new AssuranceCase.
- Payload: `{'name': <str:case_name>, 'description': <str:description>}`
- returns `{name: <str:case_name>, id: <int:case_id>}`

### `/cases/<int:case_id>`
* A GET request will get the full JSON of the specified AssuranceCase and all its children:
* A GET request will get the full JSON of the specified AssuranceCase and all its children:
- returns `{name: <str:case_name>, id: <int:case_id>, description: <str:description>, created_date: <datetime:date>, goals: [SERIALIZED_GOAL]}`, where a "SERIALIZED_GOAL" is the same as the output of a GET request to `/goals/<int:goal_id>` (see below).
* A PUT request will modify new AssuranceCase.
* A PUT request will modify new AssuranceCase.
- Payload: Any key/value pair from the AssuranceCase schema
- returns `{name: <str:case_name>, id: <int:case_id>, description: <str:description>, created_date: <datetime:date>, goals: [<int:goal_ids>]}`
* A DELETE request will delete the specified AssuranceCase.
- returns `[{name: <str:case_name>, id: <int:case_id>}, ...]` listing remaining AssuranceCases

### `/goals/`
* A GET request will list the available TopLevelNormativeGoals:
* A GET request will list the available TopLevelNormativeGoals:
- returns `[{name: <str:goal_name>, id: <int:goal_id>}, ...]`
* A POST request will create a new TopLevelNormativeGoal.
* A POST request will create a new TopLevelNormativeGoal.
- Payload: `{name: <str:goal_name>, short_description: <str:description>, long_description : <str:description>, keywords: <str:keywords>, assurance_case_id: <int:case_id>}`
- returns `{name: <str:goal_name>, id: <int:goal_id>}`

### `/goals/<int:goal_id>`
* A GET request will get the full JSON containing details of the specified TopLevelNormativeGoal and all its children:
* A GET request will get the full JSON containing details of the specified TopLevelNormativeGoal and all its children:
- returns `{name: <str:goal_name>, id: <int:goal_id>, short_description: <str:description>, long_description: <str:description>, keywords: <str:keywords>, contexts: [SERIALIZED_CONTEXT], system_description: [SERIALIZED_DESCRIPTION], property_claims: [SERIALIZED_CLAIM]`, where "SERIALIZED_CONTEXT" and "SERIALIZED_DESCRIPTION" are the same as the responses to GET requests to `/contexts/<int:context_id>` and `/descriptions/<int:desc_id>` respectively (see below), and "SERIALIZED_CLAIM" is the full nested JSON containing the details from a GET request to `propertyclaims/<int:claim_id>` and also the JSON from all its children.
* A PUT request will modify the specified TopLevelNormativeGoal.
* A PUT request will modify the specified TopLevelNormativeGoal.
- Payload: Any key/value pair from the TopLevelNormativeGoal schema
- returns `{name: <str:goal_name>, id: <int:goal_id>, short_description: <str:description>, long_description: <str:description>, keywords: <str:keywords>, contexts: [<int:context_ids>], system_description: [<int:system_description_id>], assurance_case,: <dict:serialized_assurance_case>, shape: <str:shape>}`
* A DELETE request will delete the specified TopLevelNormativeGoal.
- returns `[{name: <str:goal_name>, id: <int:goal_id>}, ...]` listing remaining TopLevelNormativeGoals

### `/contexts/`
* A GET request will list the available Contexts:
* A GET request will list the available Contexts:
- returns `[{name: <str:context_name>, id: <int:context_id>}, ...]`
* A POST request will create a new Context.
* A POST request will create a new Context.
- Payload: `{name: <str:context_name>, short_description: <str:description>, long_description : <str:description>, goal_id: <int:goal_id>}`
- returns `{name: <str:context_name>, id: <int:context_id>}`

### `/contexts/<int:context_id>`
* A GET request will get the details of the specified Context:
* A GET request will get the details of the specified Context:
- returns `{name: <str:context_name>, id: <int:context_id>, short_description: <str:description>, long_description: <str:description>, created_date: <datetime:date>, shape: <str:shape>}`
* A PUT request will modify the specified Context.
* A PUT request will modify the specified Context.
- Payload: dict containing any key/value pairs from the Context schema
- returns `{name: <str:context_name>, id: <int:context_id>, short_description: <str:description>, long_description: <str:description>, goal: <dict:serialized_toplevelnormativegoal>}`
* A DELETE request will delete the specified Context.
- returns `[{name: <str:context_name>, id: <int:context_id>}, ...]` listing remaining Contexts

### `/descriptions/`
* A GET request will list the available SystemDescriptions:
* A GET request will list the available SystemDescriptions:
- returns `[{name: <str:description_name>, id: <int:description_id>}, ...]`
* A POST request will create a new SystemDescription.
* A POST request will create a new SystemDescription.
- Payload: `{name: <str:description_name>, short_description: <str:description>, long_description : <str:description>, goal_id: <int:goal_id>}`
- returns `{name: <str:description_name>, id: <int:description_id>}`

### `/descriptions/<int:description_id>`
* A GET request will get the details of the specified SystemDescription:
* A GET request will get the details of the specified SystemDescription:
- returns `{name: <str:description_name>, id: <int:description_id>, short_description: <str:description>, long_description: <str:description>, shape: <str:shape>}`
* A PUT request will modify the specified SystemDescription.
* A PUT request will modify the specified SystemDescription.
- Payload: dict containing any key/value pairs from the SystemDescription schema
- returns `{name: <str:description_name>, id: <int:description_id>, short_description: <str:description>, long_description: <str:description>}`
* A DELETE request will delete the specified SystemDescription.
- returns `[{name: <str:description_name>, id: <int:description_id>}, ...]` listing remaining SystemDescriptions

### `/propertyclaims/`
* A GET request will list the available PropertyClaims:
* A GET request will list the available PropertyClaims:
- returns `[{name: <str:claim_name>, id: <int:claim_id>}, ...]`
* A POST request will create a new PropertyClaim.
* A POST request will create a new PropertyClaim.
- Payload: `{name: <str:claim_name>, short_description: <str:description>, long_description : <str:description>, goal_id: <int:goal_id>}`
- returns `{name: <str:claim_name>, id: <int:claim_id>}`

### `/propertyclaims/<int:claim_id>`
* A GET request will get the details of the specified PropertyClaim:
* A GET request will get the details of the specified PropertyClaim:
- returns `{name: <str:claim_name>, id: <int:claim_id>, short_description: <str:description>, long_description: <str:description>, arguments: [<int:argument_id>], shape: <str:shape>}`
* A PUT request will modify the specified PropertyClaim.
* A PUT request will modify the specified PropertyClaim.
- Payload: dict containing any key/value pairs from the PropertyClaim schema
- returns `{name: <str:claim_name>, id: <int:claim_id>, short_description: <str:description>, long_description: <str:description>, goal: <dict:serialized_toplevelnormativegoal>}`
* A DELETE request will delete the specified PropertyClaim.
- returns `[{name: <str:claim_name>, id: <int:claim_id>}, ...]` listing remaining PropertyClaims

### `/arguments/`
* A GET request will list the available Arguments:
* A GET request will list the available Arguments:
- returns `[{name: <str:argument_name>, id: <int:argument_id>}, ...]`
* A POST request will create a new Argument.
* A POST request will create a new Argument.
- Payload: `{name: <str:argument_name>, short_description: <str:description>, long_description : <str:description>, property_claim_id: [<int:claim_ids>]}`
- returns `{name: <str:argument_name>, id: <int:argument_id>}`

### `/arguments/<int:argument_id>`
* A GET request will get the details of the specified Argument:
* A GET request will get the details of the specified Argument:
- returns `{name: <str:argument_name>, id: <int:argument_id>, short_description: <str:description>, long_description: <str:description>, evidential_claims: [<int:claim_ids>], shape: <str:shape>}`
* A PUT request will modify the specified Argument.
* A PUT request will modify the specified Argument.
- Payload: dict containing any key/value pairs from the Argument schema
- returns `{name: <str:argument_name>, id: <int:argument_id>, short_description: <str:description>, long_description: <str:description>, property_claim: [<dict:serialized_propertyclaim>]}`
* A DELETE request will delete the specified Argument.
- returns `[{name: <str:argument_name>, id: <int:argument_id>}, ...]` listing remaining Arguments

### `/evidentialclaims/`
* A GET request will list the available EvidentialClaims:
* A GET request will list the available EvidentialClaims:
- returns `[{name: <str:claim_name>, id: <int:claim_id>}, ...]`
* A POST request will create a new PropertyClaim.
* A POST request will create a new PropertyClaim.
- Payload: `{name: <str:claim_name>, short_description: <str:description>, long_description : <str:description>, argument_id: <int:argument_id>}`
- returns `{name: <str:claim_name>, id: <int:claim_id>}`

### `/evidentialclaims/<int:claim_id>`
* A GET request will get the details of the specified EvidentialClaim:
* A GET request will get the details of the specified EvidentialClaim:
- returns `{name: <str:claim_name>, id: <int:claim_id>, short_description: <str:description>, long_description: <str:description>, evidence: [<int:evidence_id>], shape: <str:shape>}`
* A PUT request will modify the specified EvidentialClaim.
* A PUT request will modify the specified EvidentialClaim.
- Payload: dict containing any key/value pairs from the EvidentialClaim schema
- returns `{name: <str:claim_name>, id: <int:claim_id>, short_description: <str:description>, long_description: <str:description>, argument: <dict:serialized_argument>}`
* A DELETE request will delete the specified EvidentialClaim.
- returns `[{name: <str:claim_name>, id: <int:claim_id>}, ...]` listing remaining EvidentialClaims

### `/evidence/`
* A GET request will list the available Evidence objects:
* A GET request will list the available Evidence objects:
- returns `[{name: <str:evidence_name>, id: <int:evidence_id>}, ...]`
* A POST request will create a new Evidence.
* A POST request will create a new Evidence.
- Payload: `{name: <str:evidence_name>, short_description: <str:description>, long_description : <str:description>, evidencial_claim_id: [<int:goal_id>]}`
- returns `{name: <str:evidence_name>, id: <int:evidence_id>}`

### `/evidence/<int:evidence_id>`
* A GET request will get the details of the specified Evidence:
* A GET request will get the details of the specified Evidence:
- returns `{name: <str:evidence_name>, id: <int:evidence_id>, short_description: <str:description>, long_description: <str:description>, URL: <str:url>, shape: <str:shape>}`
* A PUT request will modify the specified Evidence.
* A PUT request will modify the specified Evidence.
- Payload: dict containing any key/value pairs from the Evidence schema
- returns `{name: <str:claim_name>, id: <int:claim_id>, short_description: <str:description>, long_description: <str:description>, URL: <str:url>, evidential_claim: [<dict:serialized_evidentialclaim>]}`
* A DELETE request will delete the specified Evidence.
Expand Down
2 changes: 1 addition & 1 deletion eap_backend/eap_api/admin.py
Expand Up @@ -20,4 +20,4 @@
admin.site.register(PropertyClaim)
admin.site.register(Argument)
admin.site.register(EvidentialClaim)
admin.site.register(Evidence)
admin.site.register(Evidence)
34 changes: 17 additions & 17 deletions eap_backend/eap_api/migrations/0005_auto_20211109_1840.py
Expand Up @@ -6,40 +6,40 @@
class Migration(migrations.Migration):

dependencies = [
('eap_api', '0004_auto_20211026_1712'),
("eap_api", "0004_auto_20211026_1712"),
]

operations = [
migrations.RemoveField(
model_name='argument',
name='shape',
model_name="argument",
name="shape",
),
migrations.RemoveField(
model_name='assurancecase',
name='shape',
model_name="assurancecase",
name="shape",
),
migrations.RemoveField(
model_name='context',
name='shape',
model_name="context",
name="shape",
),
migrations.RemoveField(
model_name='evidence',
name='shape',
model_name="evidence",
name="shape",
),
migrations.RemoveField(
model_name='evidentialclaim',
name='shape',
model_name="evidentialclaim",
name="shape",
),
migrations.RemoveField(
model_name='propertyclaim',
name='shape',
model_name="propertyclaim",
name="shape",
),
migrations.RemoveField(
model_name='systemdescription',
name='shape',
model_name="systemdescription",
name="shape",
),
migrations.RemoveField(
model_name='toplevelnormativegoal',
name='shape',
model_name="toplevelnormativegoal",
name="shape",
),
]
38 changes: 19 additions & 19 deletions eap_backend/eap_api/migrations/0006_auto_20211109_1855.py
Expand Up @@ -6,38 +6,38 @@
class Migration(migrations.Migration):

dependencies = [
('eap_api', '0005_auto_20211109_1840'),
("eap_api", "0005_auto_20211109_1840"),
]

operations = [
migrations.RenameField(
model_name='argument',
old_name='property_claim_id',
new_name='property_claim',
model_name="argument",
old_name="property_claim_id",
new_name="property_claim",
),
migrations.RenameField(
model_name='context',
old_name='goal_id',
new_name='goal',
model_name="context",
old_name="goal_id",
new_name="goal",
),
migrations.RenameField(
model_name='evidence',
old_name='evidential_claim_id',
new_name='evidential_claim',
model_name="evidence",
old_name="evidential_claim_id",
new_name="evidential_claim",
),
migrations.RenameField(
model_name='evidentialclaim',
old_name='argument_id',
new_name='argument',
model_name="evidentialclaim",
old_name="argument_id",
new_name="argument",
),
migrations.RenameField(
model_name='propertyclaim',
old_name='goal_id',
new_name='goal',
model_name="propertyclaim",
old_name="goal_id",
new_name="goal",
),
migrations.RenameField(
model_name='systemdescription',
old_name='goal_id',
new_name='goal',
model_name="systemdescription",
old_name="goal_id",
new_name="goal",
),
]
Expand Up @@ -7,13 +7,17 @@
class Migration(migrations.Migration):

dependencies = [
('eap_api', '0006_auto_20211109_1855'),
("eap_api", "0006_auto_20211109_1855"),
]

operations = [
migrations.AlterField(
model_name='toplevelnormativegoal',
name='assurance_case',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='goals', to='eap_api.assurancecase'),
model_name="toplevelnormativegoal",
name="assurance_case",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="goals",
to="eap_api.assurancecase",
),
),
]

0 comments on commit c0286f1

Please sign in to comment.