Skip to content

Commit

Permalink
Feat/pan eu validations (#2327)
Browse files Browse the repository at this point in the history
* C1 tab validations

* Some C2 validations

* Finished C2 validations

* ignore

* fix comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
persas and mergify[bot] authored Mar 2, 2023
1 parent da2fe66 commit ca12ff4
Show file tree
Hide file tree
Showing 10 changed files with 2,205 additions and 63 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.src.legacy/webapp/main/routes.js
src/test/migrations/steps/template.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
'use strict';
'use strict'

var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var Promise;
var dbm
var type
var seed
var fs = require('fs')
var path = require('path')
var Promise

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate
type = dbm.dataType
seed = seedLink
Promise = options.Promise
}

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20230222094454-migration-steps-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);
exports.up = function (db) {
var filePath = path.join(__dirname, 'sqls', '20230222094454-migration-steps-up.sql')
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: 'utf-8' }, function (err, data) {
if (err) return reject(err)
console.log('received data: ' + data)

resolve(data);
});
resolve(data)
})
}).then(function (data) {
return db.runSql(data)
})
.then(function(data) {
return db.runSql(data);
});
};
}

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20230222094454-migration-steps-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);
exports.down = function (db) {
var filePath = path.join(__dirname, 'sqls', '20230222094454-migration-steps-down.sql')
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: 'utf-8' }, function (err, data) {
if (err) return reject(err)
console.log('received data: ' + data)

resolve(data);
});
resolve(data)
})
}).then(function (data) {
return db.runSql(data)
})
.then(function(data) {
return db.runSql(data);
});
};
}

exports._meta = {
"version": 1
};
version: 1,
}
3 changes: 2 additions & 1 deletion src/test/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'fs'
import * as path from 'path'

import { DB } from '@server/db'
import { Logger } from '@server/utils/logger'

const client = DB
let migrations: Array<string>
Expand All @@ -25,7 +26,7 @@ describe(`Migrations:`, () => {
.filter((migration: string) => !ranMigrations.includes(migration))
.sort()
.map(async (file: string) => {
console.log('Running migration', file)
Logger.log('Running migration', file)
// eslint-disable-next-line @typescript-eslint/no-var-requires,global-require,import/no-dynamic-require
return require(`./steps/${file}`).default(client)
})
Expand Down
1,653 changes: 1,651 additions & 2 deletions src/test/sectionSpec/PanEuropeanSpecs.ts

Large diffs are not rendered by default.

264 changes: 248 additions & 16 deletions src/test/sectionSpec/panEuSections/ageClassDistribution.ts

Large diffs are not rendered by default.

96 changes: 96 additions & 0 deletions src/test/sectionSpec/panEuSections/carbonStock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,18 @@ export const carbonStock = {
],
migration: {
cycles: ['2025'],
validateFns: [
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2025['above_ground'],
[table_1_4a.other_wooded_land_2025['above_ground'],table_1_4a.forest_2025['above_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2025['below_ground'],
[table_1_4a.other_wooded_land_2025['below_ground'],table_1_4a.forest_2025['below_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2025['deadwood'],
[table_1_4a.other_wooded_land_2025['deadwood'],table_1_4a.forest_2025['deadwood']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2025['litter'],
[table_1_4a.other_wooded_land_2025['litter'],table_1_4a.forest_2025['litter']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2025['soil_carbon'],
[table_1_4a.other_wooded_land_2025['soil_carbon'],table_1_4a.forest_2025['soil_carbon']])`,
],
},
labelKey: 'panEuropean.carbonStock.total_forest_and_other_wooded_land',
labelParams: { year: 2025 },
Expand All @@ -504,6 +516,20 @@ export const carbonStock = {
{ idx: 3, type: 'decimal' },
{ idx: 4, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2020['above_ground'],
[table_1_4a.other_wooded_land_2020['above_ground'],table_1_4a.forest_2020['above_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2020['below_ground'],
[table_1_4a.other_wooded_land_2020['below_ground'],table_1_4a.forest_2020['below_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2020['deadwood'],
[table_1_4a.other_wooded_land_2020['deadwood'],table_1_4a.forest_2020['deadwood']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2020['litter'],
[table_1_4a.other_wooded_land_2020['litter'],table_1_4a.forest_2020['litter']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2020['soil_carbon'],
[table_1_4a.other_wooded_land_2020['soil_carbon'],table_1_4a.forest_2020['soil_carbon']])`,
],
},
labelKey: 'panEuropean.carbonStock.total_forest_and_other_wooded_land',
labelParams: { year: 2020 },
variableExport: 'total_forest_and_other_wooded_land_2020',
Expand All @@ -529,6 +555,20 @@ export const carbonStock = {
{ idx: 3, type: 'decimal' },
{ idx: 4, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2015['above_ground'],
[table_1_4a.other_wooded_land_2015['above_ground'],table_1_4a.forest_2015['above_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2015['below_ground'],
[table_1_4a.other_wooded_land_2015['below_ground'],table_1_4a.forest_2015['below_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2015['deadwood'],
[table_1_4a.other_wooded_land_2015['deadwood'],table_1_4a.forest_2015['deadwood']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2015['litter'],
[table_1_4a.other_wooded_land_2015['litter'],table_1_4a.forest_2015['litter']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2015['soil_carbon'],
[table_1_4a.other_wooded_land_2015['soil_carbon'],table_1_4a.forest_2015['soil_carbon']])`,
],
},
labelKey: 'panEuropean.carbonStock.total_forest_and_other_wooded_land',
labelParams: { year: 2015 },
variableExport: 'total_forest_and_other_wooded_land_2015',
Expand All @@ -554,6 +594,20 @@ export const carbonStock = {
{ idx: 3, type: 'decimal' },
{ idx: 4, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2010['above_ground'],
[table_1_4a.other_wooded_land_2010['above_ground'],table_1_4a.forest_2010['above_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2010['below_ground'],
[table_1_4a.other_wooded_land_2010['below_ground'],table_1_4a.forest_2010['below_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2010['deadwood'],
[table_1_4a.other_wooded_land_2010['deadwood'],table_1_4a.forest_2010['deadwood']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2010['litter'],
[table_1_4a.other_wooded_land_2010['litter'],table_1_4a.forest_2010['litter']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2010['soil_carbon'],
[table_1_4a.other_wooded_land_2010['soil_carbon'],table_1_4a.forest_2010['soil_carbon']])`,
],
},
labelKey: 'panEuropean.carbonStock.total_forest_and_other_wooded_land',
labelParams: { year: 2010 },
variableExport: 'total_forest_and_other_wooded_land_2010',
Expand All @@ -579,6 +633,20 @@ export const carbonStock = {
{ idx: 3, type: 'decimal' },
{ idx: 4, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2005['above_ground'],
[table_1_4a.other_wooded_land_2005['above_ground'],table_1_4a.forest_2005['above_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2005['below_ground'],
[table_1_4a.other_wooded_land_2005['below_ground'],table_1_4a.forest_2005['below_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2005['deadwood'],
[table_1_4a.other_wooded_land_2005['deadwood'],table_1_4a.forest_2005['deadwood']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2005['litter'],
[table_1_4a.other_wooded_land_2005['litter'],table_1_4a.forest_2005['litter']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2005['soil_carbon'],
[table_1_4a.other_wooded_land_2005['soil_carbon'],table_1_4a.forest_2005['soil_carbon']])`,
],
},
labelKey: 'panEuropean.carbonStock.total_forest_and_other_wooded_land',
labelParams: { year: 2005 },
variableExport: 'total_forest_and_other_wooded_land_2005',
Expand All @@ -604,6 +672,20 @@ export const carbonStock = {
{ idx: 3, type: 'decimal' },
{ idx: 4, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2000['above_ground'],
[table_1_4a.other_wooded_land_2000['above_ground'],table_1_4a.forest_2000['above_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2000['below_ground'],
[table_1_4a.other_wooded_land_2000['below_ground'],table_1_4a.forest_2000['below_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2000['deadwood'],
[table_1_4a.other_wooded_land_2000['deadwood'],table_1_4a.forest_2000['deadwood']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2000['litter'],
[table_1_4a.other_wooded_land_2000['litter'],table_1_4a.forest_2000['litter']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_2000['soil_carbon'],
[table_1_4a.other_wooded_land_2000['soil_carbon'],table_1_4a.forest_2000['soil_carbon']])`,
],
},
labelKey: 'panEuropean.carbonStock.total_forest_and_other_wooded_land',
labelParams: { year: 2000 },
variableExport: 'total_forest_and_other_wooded_land_2000',
Expand All @@ -629,6 +711,20 @@ export const carbonStock = {
{ idx: 3, type: 'decimal' },
{ idx: 4, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_1990['above_ground'],
[table_1_4a.other_wooded_land_1990['above_ground'],table_1_4a.forest_1990['above_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_1990['below_ground'],
[table_1_4a.other_wooded_land_1990['below_ground'],table_1_4a.forest_1990['below_ground']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_1990['deadwood'],
[table_1_4a.other_wooded_land_1990['deadwood'],table_1_4a.forest_1990['deadwood']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_1990['litter'],
[table_1_4a.other_wooded_land_1990['litter'],table_1_4a.forest_1990['litter']])`,
`validatorEqualToSum(table_1_4a.total_forest_and_other_wooded_land_1990['soil_carbon'],
[table_1_4a.other_wooded_land_1990['soil_carbon'],table_1_4a.forest_1990['soil_carbon']])`,
],
},
labelKey: 'panEuropean.carbonStock.total_forest_and_other_wooded_land',
labelParams: { year: 1990 },
variableExport: 'total_forest_and_other_wooded_land_1990',
Expand Down
40 changes: 40 additions & 0 deletions src/test/sectionSpec/panEuSections/forestInvestment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export const totalGrossFixedCapitalFormationInForestsAndForestry = {
],
migration: {
cycles: ['2025'],
validateFns: [
`validatorEqualToSum(table_6_4a.forestry_isic_nace_02_2020['total'],
[table_6_4a.forestry_isic_nace_02_2020['other_gross_fixed_capital_formation'],table_6_4a.forestry_isic_nace_02_2020['planting_of_trees_to_provide_regular_income'],
table_6_4a.forestry_isic_nace_02_2020['equipment_and_buildings']])`,
],
},
labelKey: 'panEuropean.totalGrossFixedCapitalFormationInForestsAndForestry.forestry_isic_nace_02',
labelParams: { year: 2020 },
Expand All @@ -119,6 +124,13 @@ export const totalGrossFixedCapitalFormationInForestsAndForestry = {
},
{ idx: 3, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_6_4a.forestry_isic_nace_02_2015['total'],
[table_6_4a.forestry_isic_nace_02_2015['other_gross_fixed_capital_formation'],table_6_4a.forestry_isic_nace_02_2015['planting_of_trees_to_provide_regular_income'],
table_6_4a.forestry_isic_nace_02_2015['equipment_and_buildings']])`,
],
},
labelKey: 'panEuropean.totalGrossFixedCapitalFormationInForestsAndForestry.forestry_isic_nace_02',
labelParams: { year: 2015 },
variableExport: 'forestry_isic_nace_02_2015',
Expand All @@ -143,6 +155,13 @@ export const totalGrossFixedCapitalFormationInForestsAndForestry = {
},
{ idx: 3, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_6_4a.forestry_isic_nace_02_2010['total'],
[table_6_4a.forestry_isic_nace_02_2010['other_gross_fixed_capital_formation'],table_6_4a.forestry_isic_nace_02_2010['planting_of_trees_to_provide_regular_income'],
table_6_4a.forestry_isic_nace_02_2010['equipment_and_buildings']])`,
],
},
labelKey: 'panEuropean.totalGrossFixedCapitalFormationInForestsAndForestry.forestry_isic_nace_02',
labelParams: { year: 2010 },
variableExport: 'forestry_isic_nace_02_2010',
Expand All @@ -167,6 +186,13 @@ export const totalGrossFixedCapitalFormationInForestsAndForestry = {
},
{ idx: 3, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_6_4a.forestry_isic_nace_02_2005['total'],
[table_6_4a.forestry_isic_nace_02_2005['other_gross_fixed_capital_formation'],table_6_4a.forestry_isic_nace_02_2005['planting_of_trees_to_provide_regular_income'],
table_6_4a.forestry_isic_nace_02_2005['equipment_and_buildings']])`,
],
},
labelKey: 'panEuropean.totalGrossFixedCapitalFormationInForestsAndForestry.forestry_isic_nace_02',
labelParams: { year: 2005 },
variableExport: 'forestry_isic_nace_02_2005',
Expand All @@ -191,6 +217,13 @@ export const totalGrossFixedCapitalFormationInForestsAndForestry = {
},
{ idx: 3, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_6_4a.forestry_isic_nace_02_2000['total'],
[table_6_4a.forestry_isic_nace_02_2000['other_gross_fixed_capital_formation'],table_6_4a.forestry_isic_nace_02_2000['planting_of_trees_to_provide_regular_income'],
table_6_4a.forestry_isic_nace_02_2000['equipment_and_buildings']])`,
],
},
labelKey: 'panEuropean.totalGrossFixedCapitalFormationInForestsAndForestry.forestry_isic_nace_02',
labelParams: { year: 2000 },
variableExport: 'forestry_isic_nace_02_2000',
Expand All @@ -215,6 +248,13 @@ export const totalGrossFixedCapitalFormationInForestsAndForestry = {
},
{ idx: 3, type: 'decimal' },
],
migration: {
validateFns: [
`validatorEqualToSum(table_6_4a.forestry_isic_nace_02_1990['total'],
[table_6_4a.forestry_isic_nace_02_1990['other_gross_fixed_capital_formation'],table_6_4a.forestry_isic_nace_02_1990['planting_of_trees_to_provide_regular_income'],
table_6_4a.forestry_isic_nace_02_1990['equipment_and_buildings']])`,
],
},
labelKey: 'panEuropean.totalGrossFixedCapitalFormationInForestsAndForestry.forestry_isic_nace_02',
labelParams: { year: 1990 },
variableExport: 'forestry_isic_nace_02_1990',
Expand Down
Loading

0 comments on commit ca12ff4

Please sign in to comment.