Commit cc1ac6eb authored by PTSEFTON's avatar PTSEFTON
Browse files

Fixed some tests

parents 04e057b8 7b81e0c2
......@@ -39,6 +39,7 @@ const path = require("path")
const DEFAULTS = path.join(__dirname, '../defaults');
const defaults_dir = DEFAULTS;
const context = require(path.join(DEFAULTS, 'context.json'));
const catalog_template = path.join(DEFAULTS, 'catalog_template.html');
// DataCrate specific terms which have inverses
const back_links = {
......@@ -69,5 +70,6 @@ module.exports = {
back_back_links: back_back_links,
DataCrate_profile_file: DataCrate_profile_file,
context: context,
defaults_dir: defaults_dir
defaults_dir: defaults_dir,
catalog_template: catalog_template
};
......@@ -53,6 +53,8 @@ const back_links = {
hasMember: "memberOf"
};
const dont_back_link = new Set(Object.values(back_links));
// TODO - Put this in a utility function
const arrayify = function arrayify(something, callback) {
......@@ -606,7 +608,7 @@ module.exports = function () {
return html;
},
init: function init(crate_data, out_path, multiple_files, template_path) {
init: function init(crate_data, out_path, multiple_files, template_path=defaults.catalog_template) {
if (template_path) {
var temp = fs.readFileSync(template_path, { encoding: "utf8" });
this.template = ejs.compile(temp);
......
{
"name": "calcyte",
"version": "0.3.0",
"description": "Javascript version of the Calcyte tool for data packaging",
"version": "1.0.1",
"description": "Calcyte is a command-line tool and set of libraries for creating and managing DataCrate data packages",
"main": "index.js",
"bin": {
"calcyfy": "./calcyfy"
......
......@@ -187,7 +187,9 @@ describe("GTM", function() {
//console.log("Props", c.collection_metadata.properties);
assert.equal(c.collection_metadata.properties["name"].data, "GTM");
assert.equal(c.children.length, 0);
//console.log(c.namy_dir_lookup);
//console.log(c.things);
//assert(Object.is(c.collection_metadata, {} ));
return c.to_json_ld().then(
function() {
......@@ -336,6 +338,55 @@ describe("Sample data details", function() {
});
describe("Sample data bagged", function() {
var test_path;
before(function () { test_path = fixtures.buildup('sample') });
after(function() { fixtures.teardown('sample') });
it("Should create a bag", function() {
var c = new Collection();
c.read(test_path, "./", false, 1000);
const bag_dir = path.join(working_dir, "bags", "sample");
shell.rm("-rf", bag_dir);
shell.mkdir("-p", bag_dir);
c.bag(bag_dir);
console.log(c.collection_metadata.properties);
return c.to_json_ld().then(
function() {
//console.log("JSON-LD", JSON.stringify(c.json_ld, null, 2));
c.generate_bag_info();
c.save_bag_info();
assert.equal(c.bag_meta["Contact-Email"], "pt@ptsefton.com", "email");
assert(shell.test("-e", path.join(bag_dir, "CATALOG.json")));
assert.equal(
c.item_by_id["https://dx.doi.org/10.5281/zenodo.1009240"]["hasPart"]
.length,
2
);
assert.equal(
c.item_by_id["http://www.geonames.org/8152662/catalina-park.html"]
.name,
"Catalina Park"
);
//console.log("Place data", c.item_by_id["http://www.geonames.org/8152662/catalina-park.html"])
var catalina_location_id =
c.item_by_id["http://www.geonames.org/8152662/catalina-park.html"]
.geo["@id"];
var catalina_geo = c.item_by_id[catalina_location_id];
assert.equal(catalina_geo.latitude, "-33.7152");
assert.equal(catalina_geo.longitude, "150.30119");
},
function(err) {
console.log(err);
}
);
});
});
describe("Datacite", function() {
......
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