forked from yvv/decision
Lot T3c : les tests d'abord, rouges sur le texte de e7ab82f (8 tests) — « comme d'habitude » contre le terme défini « participation habituelle » ; une grille commune (grid, 85 100 cas : W de 100 à 10 000 000, médianes sous 1 % et au-dessus de 50 % de W ramenées par Participation::of, chaque quorum d'auteur de 2 à W jusqu'à 1 000, les cinq crans) à la place d'as_usual_grid, qui sautait les médianes hors des bornes ; l'écart entre la valeur bornée et la médiane (W 7 224, médiane 40, cran 2 : 28 « pour » sur 40, pas 27) ; la part exigée qui baisse au-delà du quorum de l'article ; « une seule voix » sur la grille ; quorum.rs : la participation et G inchangés par le quorum d'un article, le cran 3 d'un nouvel article
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,11 @@ fn numbers(levels: &Value, key: &str) -> Vec<u64> {
|
||||
levels.as_array().expect("levels").iter().map(|l| l[key].as_u64().expect("number")).collect()
|
||||
}
|
||||
|
||||
/// G of each level, as served.
|
||||
fn gradients(doc: &Value) -> Vec<Value> {
|
||||
doc["levels"].as_array().expect("levels").iter().map(|l| l["gradient"].clone()).collect()
|
||||
}
|
||||
|
||||
/// (quorum, quorumDefault, canSetQuorum) of a unit.
|
||||
fn quorum_of(u: &Value) -> (Option<u64>, Option<u64>, Option<bool>) {
|
||||
(u["quorum"].as_u64(), u["quorumDefault"].as_u64(), u["canSetQuorum"].as_bool())
|
||||
@@ -174,6 +179,8 @@ async fn the_author_of_an_article_sets_its_quorum_before_the_first_vote() {
|
||||
.await;
|
||||
let (u, text) =
|
||||
(created["unitId"].as_str().expect("unit").to_owned(), created["id"].as_str().expect("id").to_owned());
|
||||
// « Tout nouvel article commence à ce cran » (F1.2, « Par défaut »): the default level, 3.
|
||||
assert_eq!(unit_by_id(&chiara.doc("essai").await, &u)["inertia"], 3);
|
||||
// Its author may, another member may not; the test group: its level's quorum, 1.
|
||||
assert_eq!(quorum_of(unit_by_id(&chiara.doc("essai").await, &u)), (None, Some(1), Some(true)));
|
||||
assert_eq!(quorum_of(unit_by_id(&luna.doc("essai").await, &u)), (None, Some(1), Some(false)));
|
||||
@@ -270,6 +277,7 @@ async fn in_monnaie_libre_a_quorum_holds_two_voices_and_a_ballot_counts_even_pen
|
||||
chiara.login("Chiara", false).await;
|
||||
let doc = admin.doc("monnaie-libre").await;
|
||||
let doc_id = doc["doc"]["id"].as_str().expect("id").to_owned();
|
||||
let usual = (doc["doc"]["participation"].clone(), gradients(&doc));
|
||||
let i1 = unit(&doc, "I1");
|
||||
let (u, p) = (i1["id"].as_str().expect("u").to_owned(), i1["proposals"][0]["id"].as_str().expect("p").to_owned());
|
||||
// A text of the seed has no author: an administrator answers for it.
|
||||
@@ -287,6 +295,10 @@ async fn in_monnaie_libre_a_quorum_holds_two_voices_and_a_ballot_counts_even_pen
|
||||
}
|
||||
let doc = admin.doc("monnaie-libre").await;
|
||||
assert_eq!(unit(&doc, "I1")["proposals"][0]["evaluation"]["quorum"], 20);
|
||||
// « Elle ne dépend pas du quorum d'un article » (N1.1, lot T3c): the participation habituelle,
|
||||
// and G of each level, stay as they were (the reference rests on the document's, 2 × 50 / W).
|
||||
assert_eq!((doc["doc"]["participation"].clone(), gradients(&doc)), usual);
|
||||
assert!((doc["doc"]["participation"]["ratio"].as_f64().expect("p̃") - 100.0 / W as f64).abs() < 1e-12);
|
||||
// A refused ballot, an expired one, are no vote.
|
||||
ballot(&state, &doc_id, &p, "refused", 1).await;
|
||||
ballot(&state, &doc_id, &p, "expired", 2).await;
|
||||
|
||||
Reference in New Issue
Block a user