Skip to content

Commit

Permalink
Merge pull request #413 from alphagov/update-brief-api-stub
Browse files Browse the repository at this point in the history
Update Brief API stub
  • Loading branch information
katstevens authored Jun 26, 2018
2 parents de2267d + 96ba833 commit f26efa3
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 121 deletions.
2 changes: 1 addition & 1 deletion dmutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import flask_featureflags # noqa


__version__ = '39.3.0'
__version__ = '39.4.0'
11 changes: 11 additions & 0 deletions dmutils/api_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ def format_datetime(datetime_utc):

def brief(status="draft",
framework_slug="digital-outcomes-and-specialists",
framework_status="live",
lot_slug="digital-specialists",
lot_name="Digital Specialists",
user_id=123,
framework_name="Digital Outcomes and Specialists",
framework_family="digital-outcomes-and-specialists",
Expand All @@ -185,7 +187,16 @@ def brief(status="draft",
"frameworkSlug": framework_slug,
"frameworkName": framework_name,
"frameworkFramework": framework_family,
"frameworkStatus": framework_status,
"framework": {
"family": framework_family,
"name": framework_name,
"slug": framework_slug,
"status": framework_status,
},
"lotName": lot_name,
"lotSlug": lot_slug,
"isACopy": False,
"status": status,
"users": [{"active": True,
"role": "buyer",
Expand Down
294 changes: 174 additions & 120 deletions tests/test_api_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,135 +395,189 @@ def test_with_users(self):
assert set(supplier_framework['countersignedDetails'].keys()) == {'approvedByUserId'}


def test_brief():
assert api_stubs.brief() \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "digital-outcomes-and-specialists",
"frameworkName": "Digital Outcomes and Specialists",
"frameworkFramework": "digital-outcomes-and-specialists",
"lotSlug": "digital-specialists",
"status": "draft",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 123,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"clarificationQuestions": [],
class TestBrief:

def test_brief_defaults(self):
assert api_stubs.brief() \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "digital-outcomes-and-specialists",
"frameworkStatus": "live",
"frameworkName": "Digital Outcomes and Specialists",
"frameworkFramework": "digital-outcomes-and-specialists",
"framework": {
"family": "digital-outcomes-and-specialists",
"name": "Digital Outcomes and Specialists",
"slug": "digital-outcomes-and-specialists",
"status": "live"
},
"isACopy": False,
"lotName": "Digital Specialists",
"lotSlug": "digital-specialists",
"status": "draft",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 123,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"clarificationQuestions": [],
}
}
}

assert api_stubs.brief(
status='live',
framework_slug='a-framework-slug',
lot_slug='a-lot-slug', user_id=234,
framework_name='A Framework Name',
framework_family='a framework framework') \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "a-framework-slug",
"frameworkName": "A Framework Name",
"frameworkFramework": "a framework framework",
"lotSlug": "a-lot-slug",
"status": "live",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 234,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"publishedAt": "2016-03-29T10:11:14.000000Z",
"applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
"clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
"clarificationQuestionsAreClosed": False,
"clarificationQuestions": [],
def test_brief_framework_and_lot(self):
assert api_stubs.brief(
status='live',
framework_slug='a-framework-slug',
framework_status='coming',
lot_name="A Lot Slug",
lot_slug='a-lot-slug',
user_id=234,
framework_name='A Framework Name',
framework_family='a framework framework') \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "a-framework-slug",
"frameworkStatus": "coming",
"frameworkName": "A Framework Name",
"frameworkFramework": "a framework framework",
"framework": {
"family": "a framework framework",
"name": "A Framework Name",
"slug": "a-framework-slug",
"status": "coming"
},
"isACopy": False,
"lotSlug": "a-lot-slug",
"lotName": "A Lot Slug",
"status": "live",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 234,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"publishedAt": "2016-03-29T10:11:14.000000Z",
"applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
"clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
"clarificationQuestionsAreClosed": False,
"clarificationQuestions": [],
}
}
}

assert api_stubs.brief(clarification_questions=[{"question": "Why?", "answer": "Because"}]) \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "digital-outcomes-and-specialists",
"frameworkName": "Digital Outcomes and Specialists",
"frameworkFramework": "digital-outcomes-and-specialists",
"lotSlug": "digital-specialists",
"status": "draft",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 123,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"clarificationQuestions": [{
"question": "Why?",
"answer": "Because"
}],
def test_brief_clarification_questions(self):
assert api_stubs.brief(clarification_questions=[{"question": "Why?", "answer": "Because"}]) \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "digital-outcomes-and-specialists",
"frameworkStatus": "live",
"frameworkName": "Digital Outcomes and Specialists",
"frameworkFramework": "digital-outcomes-and-specialists",
"framework": {
"family": "digital-outcomes-and-specialists",
"name": "Digital Outcomes and Specialists",
"slug": "digital-outcomes-and-specialists",
"status": "live"
},
"isACopy": False,
"lotName": "Digital Specialists",
"lotSlug": "digital-specialists",
"status": "draft",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 123,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"clarificationQuestions": [{
"question": "Why?",
"answer": "Because"
}],
}
}
}

assert api_stubs.brief(status='live', clarification_questions_closed=True) \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "digital-outcomes-and-specialists",
"frameworkName": "Digital Outcomes and Specialists",
"frameworkFramework": "digital-outcomes-and-specialists",
"lotSlug": "digital-specialists",
"status": "live",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 123,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"publishedAt": "2016-03-29T10:11:14.000000Z",
"applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
"clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
"clarificationQuestionsAreClosed": True,
"clarificationQuestions": [],
def test_brief_clarification_questions_closed(self):
assert api_stubs.brief(status='live', clarification_questions_closed=True) \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "digital-outcomes-and-specialists",
"frameworkStatus": "live",
"frameworkName": "Digital Outcomes and Specialists",
"frameworkFramework": "digital-outcomes-and-specialists",
"framework": {
"family": "digital-outcomes-and-specialists",
"name": "Digital Outcomes and Specialists",
"slug": "digital-outcomes-and-specialists",
"status": "live"
},
"isACopy": False,
"lotName": "Digital Specialists",
"lotSlug": "digital-specialists",
"status": "live",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 123,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"publishedAt": "2016-03-29T10:11:14.000000Z",
"applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
"clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
"clarificationQuestionsAreClosed": True,
"clarificationQuestions": [],
}
}
}

assert api_stubs.brief(
status='closed',
framework_slug='a-framework-slug',
lot_slug='a-lot-slug', user_id=234,
framework_name='A Framework Name') \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "a-framework-slug",
"frameworkName": "A Framework Name",
"frameworkFramework": "digital-outcomes-and-specialists",
"lotSlug": "a-lot-slug",
"status": "closed",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 234,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"publishedAt": "2016-03-29T10:11:14.000000Z",
"applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
"clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
"clarificationQuestionsAreClosed": False,
"clarificationQuestions": [],
def test_closed_brief(self):
assert api_stubs.brief(
status='closed',
framework_slug='a-framework-slug',
lot_slug='a-lot-slug', user_id=234,
framework_name='A Framework Name') \
== {
"briefs": {
"id": 1234,
"title": "I need a thing to do a thing",
"frameworkSlug": "a-framework-slug",
"frameworkStatus": "live",
"frameworkName": "A Framework Name",
"frameworkFramework": "digital-outcomes-and-specialists",
"framework": {
"family": "digital-outcomes-and-specialists",
"name": "A Framework Name",
"slug": "a-framework-slug",
"status": "live"
},
"isACopy": False,
"lotName": "Digital Specialists",
"lotSlug": "a-lot-slug",
"status": "closed",
"users": [{"active": True,
"role": "buyer",
"emailAddress": "[email protected]",
"id": 234,
"name": "Buyer User"}],
"createdAt": "2016-03-29T10:11:12.000000Z",
"updatedAt": "2016-03-29T10:11:13.000000Z",
"publishedAt": "2016-03-29T10:11:14.000000Z",
"applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
"clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
"clarificationQuestionsAreClosed": False,
"clarificationQuestions": [],
}
}
}


def test_supplier():
Expand Down

0 comments on commit f26efa3

Please sign in to comment.