Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
rename resource type to resource def in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tatssato committed Feb 22, 2023
1 parent e644b3d commit 0069f8b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
32 changes: 16 additions & 16 deletions src/sensemaker_dna/sensemaker/applet_config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppEntryDef, EntryHash } from "@holochain/client";
import { cleanAllConductors, pause, runScenario } from "@holochain/tryorama";
//@ts-ignore
import { AppletConfig, AppletConfigInput, ConfigCulturalContext, ConfigMethod, ConfigResourceType, ConfigThreshold, CulturalContext, Dimension, Method, Range, Threshold } from "@neighbourhoods/sensemaker-lite-types";
import { AppletConfig, AppletConfigInput, ConfigCulturalContext, ConfigMethod, ConfigResourceDef, ConfigThreshold, CulturalContext, Dimension, Method, Range, Threshold } from "@neighbourhoods/sensemaker-lite-types";
import pkg from "tape-promise/tape";

import { setUpAliceandBob } from "./neighbourhood";
Expand Down Expand Up @@ -88,33 +88,33 @@ export default () =>

let app_entry_def: AppEntryDef = { entry_index: 0, zome_index: 0, visibility: { Public: null } };
// waiting for sensemaker-lite-types to be updated
// const resourceType: ResourceType = {
const resourceType: any = {
// const resourceDef: ResourceDef = {
const resourceDef: any = {
name: "task_item",
base_types: [app_entry_def],
dimension_ehs: [dimensionHash]
}

// waiting for sensemaker-lite-types to be updated
// const configResourceType: ConfigResourceType = {
const configResourceType: ConfigResourceType = {
name: resourceType.name,
base_types: resourceType.base_types,
// const configResourceDef: ConfigResourceDef = {
const configResourceDef: ConfigResourceDef = {
name: resourceDef.name,
base_types: resourceDef.base_types,
dimensions: [dimension]
}

const resourceTypeEh: EntryHash = await callZomeAlice(
const resourceDefEh: EntryHash = await callZomeAlice(
"sensemaker",
"create_resource_type",
resourceType,
resourceDef,
true
);
t.ok(resourceTypeEh);
t.ok(resourceDefEh);

const methodName = "total_importance_method"
const totalImportanceMethod: Method = {
name: methodName,
target_resource_type_eh: resourceTypeEh,
target_resource_type_eh: resourceDefEh,
input_dimension_ehs: [dimensionHash],
output_dimension_eh: objectiveDimensionHash,
program: { Sum: null },
Expand All @@ -123,7 +123,7 @@ export default () =>
};
const configMethod: ConfigMethod = {
name: totalImportanceMethod.name,
target_resource_type: configResourceType,
target_resource_type: configResourceDef,
input_dimensions: [dimension], // check if it's subjective (for now)
output_dimension: objectiveDimension, // check if it's objective
program: totalImportanceMethod.program, // making enum for now, in design doc it is `AST`
Expand Down Expand Up @@ -151,13 +151,13 @@ export default () =>

const culturalContext: CulturalContext = {
name: "most_important_tasks",
resource_type_eh: resourceTypeEh,
resource_type_eh: resourceDefEh,
thresholds: [threshold],
order_by: [[objectiveDimensionHash, { Biggest: null }]], // DimensionEh
};
const configCulturalContext: ConfigCulturalContext = {
name: culturalContext.name,
resource_type: configResourceType,
resource_type: configResourceDef,
thresholds: [configThreshold],
order_by: [[objectiveDimension, { Biggest: null }]], // DimensionEh
}
Expand All @@ -177,14 +177,14 @@ export default () =>
importance: dimensionHash,
total_importance: objectiveDimensionHash
},
resource_types: { task_item: resourceTypeEh },
resource_types: { task_item: resourceDefEh },
methods: { total_importance_method: methodEh },
cultural_contexts: { most_important_tasks: contextEh },
}
const appletConfigInput: AppletConfigInput = {
name: appletConfig.name,
dimensions: [dimension, objectiveDimension],
resource_types: [configResourceType],
resource_types: [configResourceDef],
methods: [configMethod],
cultural_contexts: [configCulturalContext],
}
Expand Down
14 changes: 7 additions & 7 deletions src/sensemaker_dna/sensemaker/community_activator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default () => test("test CA progenitor pattern", async (t) => {
createDimension,
true
)

// Bob creates a dimension but fails
try {
await callZomeBob(
Expand All @@ -95,18 +95,18 @@ export default () => test("test CA progenitor pattern", async (t) => {
});
}

const createResourceType = {
const createResourceDef = {
"name": "angryPost",
//@ts-ignore
"base_types": [readPostOutput.signed_action.hashed.content.entry_type.App],
"dimension_ehs": [createDimensionEntryHash],
}

// Alice creates a resource type
const createResourceTypeEntryHash: EntryHash = await callZomeAlice(
const createResourceDefEntryHash: EntryHash = await callZomeAlice(
"sensemaker",
"create_resource_type",
createResourceType,
createResourceDef,
true
);

Expand All @@ -118,7 +118,7 @@ export default () => test("test CA progenitor pattern", async (t) => {
await callZomeBob(
"sensemaker",
"create_resource_type",
createResourceType,
createResourceDef,
true
);
} catch (e) {
Expand All @@ -137,7 +137,7 @@ export default () => test("test CA progenitor pattern", async (t) => {
// Alice creates a method
const totalLikenessMethod = {
"name": "total_likeness_method",
"target_resource_type_eh": createResourceTypeEntryHash,
"target_resource_type_eh": createResourceDefEntryHash,
"input_dimension_ehs": [createDimensionEntryHash],
"output_dimension_eh": createDimensionEntryHash,
"program": { "Sum": null },
Expand Down Expand Up @@ -176,7 +176,7 @@ export default () => test("test CA progenitor pattern", async (t) => {
}
const culturalContext = {
"name": "testcontext",
"resource_type_eh": createResourceTypeEntryHash,
"resource_type_eh": createResourceDefEntryHash,
"thresholds": [threshold],
"order_by": [[createDimensionEntryHash, { "Biggest": null }]], // DimensionEh
}
Expand Down
42 changes: 21 additions & 21 deletions src/sensemaker_dna/sensemaker/neighbourhood.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default () => {
readPostOutput.signed_action.hashed.content.entry_type.App
);

const createResourceType = {
const createResourceDef = {
name: "angryPost",
//@ts-ignore
base_types: [
Expand All @@ -213,28 +213,28 @@ export default () => {
};

// Alice creates a resource type
const createResourceTypeEntryHash: EntryHash = await callZomeAlice(
const createResourceDefEntryHash: EntryHash = await callZomeAlice(
"sensemaker",
"create_resource_type",
createResourceType,
createResourceDef,
true
);
t.ok(createResourceTypeEntryHash);
t.ok(createResourceDefEntryHash);

// Wait for the created entry to be propagated to the other node.
await pause(pauseDuration);

// Bob gets the created resource type
const createResourceTypeReadOutput: Record = await callZomeBob(
const createResourceDefReadOutput: Record = await callZomeBob(
"sensemaker",
"get_resource_type",
createResourceTypeEntryHash,
createResourceDefEntryHash,
true
);
t.deepEqual(
createResourceType,
createResourceDef,
decode(
(createResourceTypeReadOutput.entry as any).Present.entry
(createResourceDefReadOutput.entry as any).Present.entry
) as any
);

Expand Down Expand Up @@ -331,7 +331,7 @@ export default () => {
// create a method
const totalLikenessMethod = {
name: "total_likeness_method",
target_resource_type_eh: createResourceTypeEntryHash,
target_resource_type_eh: createResourceDefEntryHash,
input_dimension_ehs: [createDimensionEntryHash],
output_dimension_eh: createObjectiveDimensionEntryHash,
program: { Sum: null },
Expand Down Expand Up @@ -549,7 +549,7 @@ export default () => {
decode((createReadOutput.entry as any).Present.entry) as any
);

const createResourceType = {
const createResourceDef = {
name: "angryPost",
//@ts-ignore
base_types: [
Expand All @@ -560,28 +560,28 @@ export default () => {
};

// Alice creates a resource type
const createResourceTypeEntryHash: EntryHash = await callZomeAlice(
const createResourceDefEntryHash: EntryHash = await callZomeAlice(
"sensemaker",
"create_resource_type",
createResourceType,
createResourceDef,
true
);
t.ok(createResourceTypeEntryHash);
t.ok(createResourceDefEntryHash);

// Wait for the created entry to be propagated to the other node.
await pause(pauseDuration);

// Bob gets the created resource type
const createResourceTypeReadOutput: Record = await callZomeBob(
const createResourceDefReadOutput: Record = await callZomeBob(
"sensemaker",
"get_resource_type",
createResourceTypeEntryHash,
createResourceDefEntryHash,
true
);
t.deepEqual(
createResourceType,
createResourceDef,
decode(
(createResourceTypeReadOutput.entry as any).Present.entry
(createResourceDefReadOutput.entry as any).Present.entry
) as any
);

Expand Down Expand Up @@ -716,7 +716,7 @@ export default () => {
// create a method
const totalLikenessMethod = {
name: "total_likeness_method",
target_resource_type_eh: createResourceTypeEntryHash,
target_resource_type_eh: createResourceDefEntryHash,
input_dimension_ehs: [createDimensionEntryHash],
output_dimension_eh: createObjectiveDimensionEntryHash,
program: { Sum: null },
Expand Down Expand Up @@ -876,7 +876,7 @@ export default () => {
};
const culturalContext = {
name: "more than 5 total likeness, biggest to smallest",
resource_type_eh: createResourceTypeEntryHash,
resource_type_eh: createResourceDefEntryHash,
thresholds: [threshold],
order_by: [[createObjectiveDimensionEntryHash, { Biggest: null }]], // DimensionEh
};
Expand All @@ -891,7 +891,7 @@ export default () => {

const culturalContext2 = {
name: "more than 5 total likeness, smallest to biggest",
resource_type_eh: createResourceTypeEntryHash,
resource_type_eh: createResourceDefEntryHash,
thresholds: [threshold],
order_by: [[createObjectiveDimensionEntryHash, { Smallest: null }]], // DimensionEh
};
Expand All @@ -906,7 +906,7 @@ export default () => {

const culturalContext3 = {
name: "float threshold",
resource_type_eh: createResourceTypeEntryHash,
resource_type_eh: createResourceDefEntryHash,
thresholds: [threshold2],
order_by: [[createObjectiveDimensionEntryHash, { Smallest: null }]], // DimensionEh
};
Expand Down

0 comments on commit 0069f8b

Please sign in to comment.