Skip to content

Commit

Permalink
Merge pull request #508 from alan-turing-institute/carlos-development
Browse files Browse the repository at this point in the history
Testing consistent identifiers when creating multiple strategies
  • Loading branch information
cptanalatriste authored Jun 24, 2024
2 parents 66466c3 + ada0fef commit ef3061e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Please remember to enable `pre-commit` and run it before any push or PR.

```bash
pre-commit install
pre-commit run a--all-files
pre-commit run --all-files
```

### Contributing to the Documentation
Expand Down
35 changes: 35 additions & 0 deletions eap_backend/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
EAPUser,
Evidence,
PropertyClaim,
Strategy,
TopLevelNormativeGoal,
)
from eap_api.serializers import (
Expand Down Expand Up @@ -166,6 +167,40 @@ def test_goal_delete_with_standard_permission(self):
assert len(response_get.json()) == 0


class StrategyViewTest(TestCase):
def setUp(self):
self.assurance_case: AssuranceCase = AssuranceCase.objects.create(**CASE1_INFO)

self.goal: TopLevelNormativeGoal = TopLevelNormativeGoal.objects.create(
**GOAL_INFO
)

def test_identifier_update_follows_order(self):
number_of_strategies: int = 3
for strategy_number in range(1, number_of_strategies + 1):
post_data = {
"name": "",
"short_description": "Strategy for The Goal",
"long_description": "A longer description of the strategy",
"goal_id": 1,
}
response_post: HttpResponse = self.client.post(
reverse("strategies_list"),
data=json.dumps(post_data),
content_type="application/json",
)

assert response_post.status_code == 201
assert response_post.json()["name"] == f"S{strategy_number}"

created_strategy: Strategy = Strategy.objects.get(
pk=response_post.json()["id"]
)

assert created_strategy.pk == response_post.json()["id"]
assert created_strategy.name == f"S{strategy_number}"


class ContextViewTest(TestCase):
def setUp(self):
# Mock Entries to be modified and tested
Expand Down

0 comments on commit ef3061e

Please sign in to comment.