Skip to content

Commit

Permalink
Merge branch 'main' into tally-community-tool
Browse files Browse the repository at this point in the history
  • Loading branch information
cong-or committed Jun 2, 2023
2 parents c3fb112 + 3172c58 commit 00c546f
Show file tree
Hide file tree
Showing 14 changed files with 1,243 additions and 1,581 deletions.
18 changes: 12 additions & 6 deletions book/src/07_web_api/openapi/core_backend_api.yaml
Expand Up @@ -1100,19 +1100,25 @@ components:
* True - **MUST** include a note.
map:
type: array
item: string
description: |-
Optional sequential list of mapped named values for rating scores.
* If not present, the rating score is numeric.
* If present:
* all possible rating scores must be represented with mapped names and the rating is represented by the value in the map.
* The lowest numbered score comes first in the array.
* The array is sequential with no gaps.
example:
- NA
- FilteredOut
- Good
- Excellent
items:
type: object
additionalProperties: true
properties:
name:
type: string
description: Symbolic Name for the metric score.
desc:
type: string
description: Description of what the named metric score means.
required:
- name
group:
type: string
description: The reviewer group who can create this review type.
Expand Down
126 changes: 59 additions & 67 deletions src/cat-data-service/src/service/v1/event/ballots.rs
Expand Up @@ -46,16 +46,7 @@ mod tests {
body::{Body, HttpBody},
http::{Request, StatusCode},
};
use event_db::types::{
event::{
ballot::{
Ballot, BallotType, GroupVotePlans, ObjectiveChoices, ProposalBallot, VotePlan,
},
objective::ObjectiveId,
proposal::ProposalId,
},
registration::VoterGroupId,
};
use std::str::FromStr;
use tower::ServiceExt;

#[tokio::test]
Expand All @@ -71,65 +62,66 @@ mod tests {
assert_eq!(response.status(), StatusCode::OK);

assert_eq!(
serde_json::to_string(&vec![ObjectiveBallots {
objective_id: ObjectiveId(1),
ballots: vec![
ProposalBallot {
proposal_id: ProposalId(1),
ballot: Ballot {
choices: ObjectiveChoices(vec!["yes".to_string(), "no".to_string()]),
voteplans: GroupVotePlans(vec![
VotePlan {
chain_proposal_index: 10,
group: VoterGroupId("direct".to_string()),
ballot_type: BallotType("public".to_string()),
chain_voteplan_id: "1".to_string(),
encryption_key: None,
},
VotePlan {
chain_proposal_index: 12,
group: VoterGroupId("rep".to_string()),
ballot_type: BallotType("public".to_string()),
chain_voteplan_id: "2".to_string(),
encryption_key: None,
}
]),
},
},
ProposalBallot {
proposal_id: ProposalId(2),
ballot: Ballot {
choices: ObjectiveChoices(vec!["yes".to_string(), "no".to_string()]),
voteplans: GroupVotePlans(vec![
VotePlan {
chain_proposal_index: 11,
group: VoterGroupId("direct".to_string()),
ballot_type: BallotType("public".to_string()),
chain_voteplan_id: "1".to_string(),
encryption_key: None,
},
VotePlan {
chain_proposal_index: 13,
group: VoterGroupId("rep".to_string()),
ballot_type: BallotType("public".to_string()),
chain_voteplan_id: "2".to_string(),
encryption_key: None,
}
]),
serde_json::Value::from_str(
String::from_utf8(response.into_body().data().await.unwrap().unwrap().to_vec())
.unwrap()
.as_str()
)
.unwrap(),
serde_json::json!([
{
"objective_id": 1,
"ballots": [
{
"proposal_id": 1,
"ballot": {
"choices": ["yes", "no"],
"voteplans": [
{
"chain_proposal_index": 10,
"group": "direct",
"ballot_type": "public",
"chain_voteplan_id": "1",
},
{
"chain_proposal_index": 12,
"group": "rep",
"ballot_type": "public",
"chain_voteplan_id": "2",
}
]
}
},
},
ProposalBallot {
proposal_id: ProposalId(3),
ballot: Ballot {
choices: ObjectiveChoices(vec!["yes".to_string(), "no".to_string()]),
voteplans: GroupVotePlans(vec![]),
{
"proposal_id": 2,
"ballot": {
"choices": ["yes", "no"],
"voteplans": [
{
"chain_proposal_index": 11,
"group": "direct",
"ballot_type": "public",
"chain_voteplan_id": "1",
},
{
"chain_proposal_index": 13,
"group": "rep",
"ballot_type": "public",
"chain_voteplan_id": "2",
}
]
}
},
}
]
}],)
.unwrap(),
String::from_utf8(response.into_body().data().await.unwrap().unwrap().to_vec())
.unwrap()
{
"proposal_id": 3,
"ballot": {
"choices": ["yes", "no"],
"voteplans": []
}
}
]
}
])
);
}
}

0 comments on commit 00c546f

Please sign in to comment.