there is reunion schema but an agenda schema

parent 5748d35d
......@@ -35,7 +35,7 @@ export class Plugin extends BasePlugin {
filename2date: any
constructor(options: any) {
super(options, "reunion-00002")
super(options, "agenda-00002")
}
preCheck(): any {
......@@ -73,21 +73,21 @@ export class Plugin extends BasePlugin {
}
}
check(reunion: any, filename: any): any {
check(agenda: any, filename: any): any {
if (
reunion.xsiType != "seance_type" ||
reunion.lieu.code != "AN" ||
reunion.cycleDeVie.etat == "Supprimé" ||
reunion.cycleDeVie.etat == "Annulé"
agenda.xsiType != "seance_type" ||
agenda.lieu.code != "AN" ||
agenda.cycleDeVie.etat == "Supprimé" ||
agenda.cycleDeVie.etat == "Annulé"
)
return null
if (this.options.verbose) console.log(`reunion-00002: ${filename}`)
if (this.options.verbose) console.log(`agenda-00002: ${filename}`)
let status = "ok"
let info: any = []
const dateSeance = new Date(
reunion.identifiants.dateSeance.substring(0, 10),
agenda.identifiants.dateSeance.substring(0, 10),
)
const year = dateSeance.toLocaleDateString("fr", { year: "numeric" })
const day = dateSeance.toLocaleDateString("fr", { day: "2-digit" })
......@@ -98,8 +98,8 @@ export class Plugin extends BasePlugin {
let idJo
if (
reunion.identifiants == undefined ||
reunion.identifiants.idJo == undefined
agenda.identifiants == undefined ||
agenda.identifiants.idJo == undefined
) {
const week = 7 * 24 * 60 * 60 * 1000
if (dateSeance >= new Date(new Date().getTime() - week)) {
......@@ -108,15 +108,15 @@ export class Plugin extends BasePlugin {
idJo = undefined
}
} else {
idJo = reunion.identifiants.idJo
idJo = agenda.identifiants.idJo
}
if (reunion.uid in remapJo) {
if (idJo == remapJo[reunion.uid]) {
if (agenda.uid in remapJo) {
if (idJo == remapJo[agenda.uid]) {
info.push(`idJo already is ${idJo}`)
status = "already-fixed"
} else {
idJo = remapJo[reunion.uid]
idJo = remapJo[agenda.uid]
status = "will-be-fixed"
}
}
......@@ -167,7 +167,7 @@ export class Plugin extends BasePlugin {
postCheck(analysis: any): any {
for (const filename of Object.keys(analysis)) {
const result = analysis[filename]["reunion-00002"]
const result = analysis[filename]["agenda-00002"]
if (result == null || result["status"] != "needs-fixing") continue
const info = result["info"].join("")
if (
......@@ -179,20 +179,20 @@ export class Plugin extends BasePlugin {
}
}
fix(reunion: any): any {
if (!(reunion.uid in remapJo)) {
fix(agenda: any): any {
if (!(agenda.uid in remapJo)) {
return null
}
const idJo = remapJo[reunion.uid]
const idJo = remapJo[agenda.uid]
const numSeanceJo = String(Number(idJo.substring(5)))
if (
reunion.identifiants.idJo == idJo &&
reunion.identifiants.numSeanceJo == numSeanceJo
agenda.identifiants.idJo == idJo &&
agenda.identifiants.numSeanceJo == numSeanceJo
)
return false
reunion.identifiants.idJo = idJo
reunion.identifiants.numSeanceJo = numSeanceJo
agenda.identifiants.idJo = idJo
agenda.identifiants.numSeanceJo = numSeanceJo
return true
}
}
......@@ -349,7 +349,7 @@ export const datasets: Datasets = {
}
const directory2schema: any = {
".*Agenda_.*": "reunion",
".*Agenda_.*": "agenda",
".*Scrutins_.*": "scrutin",
".*Amendements_.*": "amendement",
".*Dossiers_Legislatifs_.*/documents": "document",
......
......@@ -5,7 +5,7 @@ import fs from "fs-extra"
import { SchemaBugs } from "../../src/bugs"
import { BasePlugin } from "../../src/bugs"
import { Plugin as Dossier00001 } from "../../src/bugs/dossier-00001"
import { Plugin as Reunion00002 } from "../../src/bugs/reunion-00002"
import { Plugin as Agenda00002 } from "../../src/bugs/agenda-00002"
suite("bugs")
......@@ -90,9 +90,9 @@ test("#PluginDossier00001", function() {
}
})
test("#PluginReunion00002", function() {
const bug = new Reunion00002({ cr: "tests/bugs/reunion-00002" })
const d = "tests/bugs/reunion-00002"
test("#PluginAgenda00002", function() {
const bug = new Agenda00002({ cr: "tests/bugs/agenda-00002" })
const d = "tests/bugs/agenda-00002"
for (const expectedStatus of [
"will-be-fixed",
......
......@@ -23,7 +23,7 @@ test("#fixInRepository", async function() {
git.run(tmpDir, "add .")
git.run(tmpDir, "commit -m 'initial commit'")
git.run(tmpDir, "checkout --quiet -b upstream master")
git.run(tmpDir, "checkout --quiet -b upstream/master master")
write("A", `${tmpDir}/upstreamfile`)
git.run(tmpDir, "add .")
git.run(tmpDir, "commit -m 'upstream commit'")
......@@ -32,11 +32,11 @@ test("#fixInRepository", async function() {
const h = new BugsHelper({
commit: tmpDir,
schema: "reunion",
schema: "agenda",
data: `${tmpDir}/${file}`,
})
await h.fix()
assert.include(git.run(tmpDir, "log --oneline"), "Fix reunion")
assert.include(git.run(tmpDir, "log --oneline"), "Fix agenda")
assert.include(git.run(tmpDir, "log --oneline"), "upstream commit")
assert.notInclude(git.run(tmpDir, "branch"), "bugfixes")
assert.notInclude(git.run(tmpDir, "branch"), "Revert")
......@@ -48,7 +48,7 @@ test("#fixInRepository", async function() {
assert.equal(hash, git.run(tmpDir, "rev-parse HEAD"))
// upstream changes, revert and re-apply fixes
git.run(tmpDir, "checkout --quiet upstream")
git.run(tmpDir, "checkout --quiet upstream/master")
write("B", `${tmpDir}/upstreamfile`)
git.run(tmpDir, "add .")
git.run(tmpDir, "commit -m 'another upstream commit'")
......@@ -57,7 +57,7 @@ test("#fixInRepository", async function() {
await h.fix()
assert.notEqual(hash, git.run(tmpDir, "rev-parse HEAD"))
assert.equal(
'Merge bugfixes\nFix reunion-00002\nMerge upstream\nRevert "Merge bugfixes"',
'Merge bugfixes\nFix agenda-00002\nMerge upstream\nRevert "Merge bugfixes"',
git.run(tmpDir, "log --date-order -4 --format=%s"),
)
})
......@@ -71,7 +71,7 @@ test("#checkWillBeFixed", async function() {
let status = await main([
"--verbose",
"--check",
"--schema=reunion",
"--schema=agenda",
"--cr=tests/check",
"--data=tests/check/RUANR5L15S2020IDS22089.json",
])
......@@ -129,7 +129,7 @@ test("#checkCandidates", async function() {
"--verbose",
"--check",
`--output=${tmpDir}`,
"--schema=reunion",
"--schema=agenda",
"--cr=tests/check",
"--data=tests/check/RUANR5L15S2019IDS21272.json",
])
......@@ -139,13 +139,13 @@ test("#checkCandidates", async function() {
assert.deepEqual(error.args, [
[
"reunion-00002 finds tests/check/RUANR5L15S2019IDS21272.json needs-fixing",
"agenda-00002 finds tests/check/RUANR5L15S2019IDS21272.json needs-fixing",
],
["idJo field is missing\ntests/check/test_20190017.asp is a candidate"],
])
error.reset()
fs.existsSync(`${tmpDir}/reunion-00002.md`)
fs.existsSync(`${tmpDir}/agenda-00002.md`)
log.restore()
warn.restore()
......@@ -186,7 +186,7 @@ test("#main", async function() {
let status = await main([
"--verbose",
"--check",
"--schema=reunion",
"--schema=agenda",
"--cr=tests/check",
"--data=tests/check/RUANR5L15S2020IDS22089.json",
])
......
......@@ -4,7 +4,7 @@ import { datasetDirectorySchema, getSchemas, getDatasets } from "../src/datasets
suite("dataset")
test("#datasetDirectorySchema", async function() {
assert.deepEqual(datasetDirectorySchema('parent/Agenda_XV'), [['parent/Agenda_XV/**/*.json', 'reunion']])
assert.deepEqual(datasetDirectorySchema('parent/Agenda_XV'), [['parent/Agenda_XV/**/*.json', 'agenda']])
assert.deepEqual(datasetDirectorySchema('parent/Dossiers_Legislatifs_XV'), [["parent/Dossiers_Legislatifs_XV/documents/**/*.json", 'document'], ["parent/Dossiers_Legislatifs_XV/dossiers/**/*.json", 'dossier']])
for (const dataset of ['acteurs_mandats_organes', 'AMO30_tous_acteurs_tous_mandats_tous_organes_historique'])
assert.deepEqual(datasetDirectorySchema(dataset), [[`${dataset}/organes/**/*.json`, 'organe'], [`${dataset}/acteurs/**/*.json`, 'acteur']])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment