<commit_before>/* Test: phenopacket-test.ks

   Tests that our phenopackets conform to schema
   
   To run:
   NODE_PATH=./node-modules:./modules:./lib/monarch node --harmony_destructuring tests/phenopacket-test.js

 */

var fs = require('fs');
var testCommon = require('./test-common.js');
var env = require('serverenv.js');
var bbop = require('api.js').bbop;
var phenoPacketBuilder = require('../lib/monarch/phenopacket-builder.js');
var engine;
var validator = require('is-my-json-valid');


exports.testPhenoPacketBuilder = function() {

    var test_params = {};
    test_params.fq =["subject_closure:\"ClinVarVariant:156137\"",
                     "object_category:\"phenotype\""];
    test_params.q = "*:*";
    test_params.personality = "variant_phenotype";

    var limit = 5000
    var response = engine.fetchSolrDocuments(test_params.q, test_params.fq, test_params.personality, limit);
    var phenopacket = phenoPacketBuilder.buildPhenoPacket(response, test_params.personality);
    
    var schema = JSON.parse(fs.readFileSync('./tests/resources/phenopacket-schema.json', 'utf8'));

    var validate = validator(schema, {
        verbose: true
    });<commit_msg>update pheno packet unit test<commit_after>/* Test: phenopacket-test.ks

   Tests that our phenopackets conform to schema
   
   To run:
   NODE_PATH=./node-modules:./modules:./lib/monarch node --harmony_destructuring tests/phenopacket-test.js

 */

var fs = require('fs');
var testCommon = require('./test-common.js');
var env = require('serverenv.js');
var bbop = require('api.js').bbop;
var phenoPacketBuilder = require('../lib/monarch/phenopacket-builder.js');
var engine;
var validator = require('is-my-json-valid');


exports.testPhenoPacketBuilder = function() {

    var test_params = {};
    test_params.fq =["subject_closure:\"ClinVarVariant:240777\"",
                     "object_category:\"phenotype\""];
    test_params.q = "*:*";
    test_params.personality = "variant_phenotype";

    var limit = 5000
    var response = engine.fetchSolrDocuments(test_params.q, test_params.fq, test_params.personality, limit);
    var phenopacket = phenoPacketBuilder.buildPhenoPacket(response, test_params.personality);
    
    var schema = JSON.parse(fs.readFileSync('./tests/resources/phenopacket-schema.json', 'utf8'));

    var validate = validator(schema, {
        verbose: true
    });
{'fraction_non_alphanumeric': 0.1433389544688027, 'fraction_numerical': 0.00927487352445194, 'mean_word_length': 3.892783505154639, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1430242', 'n_tokens_mistral': 792, 'n_tokens_neox': 741, 'n_words': 140}