mirror of
https://github.com/edufeed-org/eventstore.git
synced 2025-12-07 15:24:32 +00:00
use new amb nip
This commit is contained in:
parent
5e16129e4c
commit
8dc0744041
3 changed files with 1004 additions and 460 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
func TestNostrToAmbEvent(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
sk := nostr.GeneratePrivateKey()
|
||||
|
|
@ -38,7 +37,6 @@ func TestNostrToAmbEvent(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
// Helper function to create a test event with a specific tag
|
||||
func createTestEvent(tags nostr.Tags) *nostr.Event {
|
||||
sk := nostr.GeneratePrivateKey()
|
||||
|
|
@ -54,24 +52,24 @@ func createTestEvent(tags nostr.Tags) *nostr.Event {
|
|||
|
||||
func TestNostrToAMB_BasicFields(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"name", "Test Resource"},
|
||||
{"description", "This is a test resource"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(event.ID, amb.ID)
|
||||
assert.Equal("test-resource-id", amb.D)
|
||||
assert.Equal("Test Resource", amb.Name)
|
||||
assert.Equal("This is a test resource", amb.Description)
|
||||
|
||||
|
||||
assert.Equal(event.ID, amb.EventID)
|
||||
assert.Equal(event.PubKey, amb.EventPubKey)
|
||||
assert.Equal(event.Content, amb.EventContent)
|
||||
|
|
@ -82,39 +80,45 @@ func TestNostrToAMB_BasicFields(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_About(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"about", "http://w3id.org/kim/schulfaecher/s1009", "Französisch", "de"},
|
||||
{"about:id", "http://w3id.org/kim/schulfaecher/s1009"},
|
||||
{"about:prefLabel", "Französisch"},
|
||||
{"about:inLanguage", "de"},
|
||||
{"about:type", "Concept"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.NotEmpty(amb.About)
|
||||
assert.Equal(1, len(amb.About))
|
||||
assert.Equal("http://w3id.org/kim/schulfaecher/s1009", amb.About[0].ID)
|
||||
assert.Equal("Französisch", amb.About[0].PrefLabel)
|
||||
assert.Equal("de", amb.About[0].InLanguage)
|
||||
assert.Equal("Concept", amb.About[0].Type)
|
||||
}
|
||||
|
||||
func TestNostrToAMB_Keywords(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"keywords", "Französisch", "Niveau A2", "Sprache"},
|
||||
{"t", "Französisch"},
|
||||
{"t", "Niveau A2"},
|
||||
{"t", "Sprache"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(3, len(amb.Keywords))
|
||||
assert.Contains(amb.Keywords, "Französisch")
|
||||
assert.Contains(amb.Keywords, "Niveau A2")
|
||||
|
|
@ -123,19 +127,19 @@ func TestNostrToAMB_Keywords(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_InLanguage(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"inLanguage", "fr"},
|
||||
{"inLanguage", "de"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.InLanguage))
|
||||
assert.Contains(amb.InLanguage, "fr")
|
||||
assert.Contains(amb.InLanguage, "de")
|
||||
|
|
@ -143,43 +147,47 @@ func TestNostrToAMB_InLanguage(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Image(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
imageURL := "https://www.tutory.de/worksheet/fbbadf1a-145a-463d-9a43-1ae9965c86b9.jpg?width=1000"
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"image", imageURL},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(imageURL, amb.Image)
|
||||
}
|
||||
|
||||
func TestNostrToAMB_Creator(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"creator", "http://author1.org", "Autorin 1", "Person"},
|
||||
{"creator", "http://author2.org", "Autorin 2", "Person"},
|
||||
{"creator:id", "http://author1.org"},
|
||||
{"creator:name", "Autorin 1"},
|
||||
{"creator:type", "Person"},
|
||||
{"creator:id", "http://author2.org"},
|
||||
{"creator:name", "Autorin 2"},
|
||||
{"creator:type", "Person"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.Creator))
|
||||
|
||||
|
||||
assert.Equal("http://author1.org", amb.Creator[0].ID)
|
||||
assert.Equal("Autorin 1", amb.Creator[0].Name)
|
||||
assert.Equal("Person", amb.Creator[0].Type)
|
||||
|
||||
|
||||
assert.Equal("http://author2.org", amb.Creator[1].ID)
|
||||
assert.Equal("Autorin 2", amb.Creator[1].Name)
|
||||
assert.Equal("Person", amb.Creator[1].Type)
|
||||
|
|
@ -187,25 +195,29 @@ func TestNostrToAMB_Creator(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Contributor(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"contributor", "http://author1.org", "Autorin 1", "Person"},
|
||||
{"contributor", "http://author2.org", "Autorin 2", "Person"},
|
||||
{"contributor:id", "http://author1.org"},
|
||||
{"contributor:name", "Autorin 1"},
|
||||
{"contributor:type", "Person"},
|
||||
{"contributor:id", "http://author2.org"},
|
||||
{"contributor:name", "Autorin 2"},
|
||||
{"contributor:type", "Person"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.Contributor))
|
||||
|
||||
|
||||
assert.Equal("http://author1.org", amb.Contributor[0].ID)
|
||||
assert.Equal("Autorin 1", amb.Contributor[0].Name)
|
||||
assert.Equal("Person", amb.Contributor[0].Type)
|
||||
|
||||
|
||||
assert.Equal("http://author2.org", amb.Contributor[1].ID)
|
||||
assert.Equal("Autorin 2", amb.Contributor[1].Name)
|
||||
assert.Equal("Person", amb.Contributor[1].Type)
|
||||
|
|
@ -213,7 +225,7 @@ func TestNostrToAMB_Contributor(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Dates(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"dateCreated", "2019-07-02"},
|
||||
|
|
@ -221,12 +233,12 @@ func TestNostrToAMB_Dates(t *testing.T) {
|
|||
{"dateModified", "2019-07-04"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal("2019-07-02", amb.DateCreated)
|
||||
assert.Equal("2019-07-03", amb.DatePublished)
|
||||
assert.Equal("2019-07-04", amb.DateModified)
|
||||
|
|
@ -234,25 +246,29 @@ func TestNostrToAMB_Dates(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Publisher(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"publisher", "http://publisher1.org", "Publisher 1", "Person"},
|
||||
{"publisher", "http://publisher2.org", "Publisher 2", "Organization"},
|
||||
{"publisher:id", "http://publisher1.org"},
|
||||
{"publisher:name", "Publisher 1"},
|
||||
{"publisher:type", "Person"},
|
||||
{"publisher:id", "http://publisher2.org"},
|
||||
{"publisher:name", "Publisher 2"},
|
||||
{"publisher:type", "Organization"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.Publisher))
|
||||
|
||||
|
||||
assert.Equal("http://publisher1.org", amb.Publisher[0].ID)
|
||||
assert.Equal("Publisher 1", amb.Publisher[0].Name)
|
||||
assert.Equal("Person", amb.Publisher[0].Type)
|
||||
|
||||
|
||||
assert.Equal("http://publisher2.org", amb.Publisher[1].ID)
|
||||
assert.Equal("Publisher 2", amb.Publisher[1].Name)
|
||||
assert.Equal("Organization", amb.Publisher[1].Type)
|
||||
|
|
@ -260,25 +276,29 @@ func TestNostrToAMB_Publisher(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Funder(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"funder", "http://funder1.org", "Funder 1", "Person"},
|
||||
{"funder", "http://funder2.org", "Funder 2", "Organization"},
|
||||
{"funder:id", "http://funder1.org"},
|
||||
{"funder:name", "Funder 1"},
|
||||
{"funder:type", "Person"},
|
||||
{"funder:id", "http://funder2.org"},
|
||||
{"funder:name", "Funder 2"},
|
||||
{"funder:type", "Organization"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.Funder))
|
||||
|
||||
|
||||
assert.Equal("http://funder1.org", amb.Funder[0].ID)
|
||||
assert.Equal("Funder 1", amb.Funder[0].Name)
|
||||
assert.Equal("Person", amb.Funder[0].Type)
|
||||
|
||||
|
||||
assert.Equal("http://funder2.org", amb.Funder[1].ID)
|
||||
assert.Equal("Funder 2", amb.Funder[1].Name)
|
||||
assert.Equal("Organization", amb.Funder[1].Type)
|
||||
|
|
@ -286,49 +306,50 @@ func TestNostrToAMB_Funder(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_IsAccessibleForFree(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"isAccessibleForFree", "true"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.True(amb.IsAccessibleForFree)
|
||||
|
||||
|
||||
// Test with "false" value
|
||||
tags = nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"isAccessibleForFree", "false"},
|
||||
}
|
||||
event = createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err = NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.False(amb.IsAccessibleForFree)
|
||||
}
|
||||
|
||||
func TestNostrToAMB_License(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"license", "https://creativecommons.org/publicdomain/zero/1.0/", "CC-0"},
|
||||
{"license:id", "https://creativecommons.org/publicdomain/zero/1.0/"},
|
||||
{"license:name", "CC-0"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.NotNil(amb.License)
|
||||
assert.Equal("https://creativecommons.org/publicdomain/zero/1.0/", amb.License.ID)
|
||||
assert.Equal("CC-0", amb.License.Name)
|
||||
|
|
@ -336,18 +357,21 @@ func TestNostrToAMB_License(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_ConditionsOfAccess(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"conditionsOfAccess", "http://w3id.org/kim/conditionsOfAccess/no_login", "Kein Login", "de"},
|
||||
{"conditionsOfAccess:id", "http://w3id.org/kim/conditionsOfAccess/no_login"},
|
||||
{"conditionsOfAccess:prefLabel", "Kein Login"},
|
||||
{"conditionsOfAccess:inLanguage", "de"},
|
||||
{"conditionsOfAccess:type", "Concept"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.NotNil(amb.ConditionsOfAccess)
|
||||
assert.Equal("http://w3id.org/kim/conditionsOfAccess/no_login", amb.ConditionsOfAccess.ID)
|
||||
assert.Equal("Kein Login", amb.ConditionsOfAccess.PrefLabel)
|
||||
|
|
@ -356,25 +380,29 @@ func TestNostrToAMB_ConditionsOfAccess(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_LearningResourceType(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"learningResourceType", "http://w3id.org/openeduhub/vocabs/new_lrt/video", "Video", "de"},
|
||||
{"learningResourceType", "http://w3id.org/openeduhub/vocabs/new_lrt/tutorial", "Tutorial", "en"},
|
||||
{"learningResourceType:id", "http://w3id.org/openeduhub/vocabs/new_lrt/video"},
|
||||
{"learningResourceType:prefLabel", "Video"},
|
||||
{"learningResourceType:inLanguage", "de"},
|
||||
{"learningResourceType:id", "http://w3id.org/openeduhub/vocabs/new_lrt/tutorial"},
|
||||
{"learningResourceType:prefLabel", "Tutorial"},
|
||||
{"learningResourceType:inLanguage", "en"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.LearningResourceType))
|
||||
|
||||
|
||||
assert.Equal("http://w3id.org/openeduhub/vocabs/new_lrt/video", amb.LearningResourceType[0].ID)
|
||||
assert.Equal("Video", amb.LearningResourceType[0].PrefLabel)
|
||||
assert.Equal("de", amb.LearningResourceType[0].InLanguage)
|
||||
|
||||
|
||||
assert.Equal("http://w3id.org/openeduhub/vocabs/new_lrt/tutorial", amb.LearningResourceType[1].ID)
|
||||
assert.Equal("Tutorial", amb.LearningResourceType[1].PrefLabel)
|
||||
assert.Equal("en", amb.LearningResourceType[1].InLanguage)
|
||||
|
|
@ -382,25 +410,29 @@ func TestNostrToAMB_LearningResourceType(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Audience(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"audience", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/student", "Schüler:in", "de"},
|
||||
{"audience", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/teacher", "Lehrer:in", "de"},
|
||||
{"audience:id", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/student"},
|
||||
{"audience:prefLabel", "Schüler:in"},
|
||||
{"audience:inLanguage", "de"},
|
||||
{"audience:id", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/teacher"},
|
||||
{"audience:prefLabel", "Lehrer:in"},
|
||||
{"audience:inLanguage", "de"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.Audience))
|
||||
|
||||
|
||||
assert.Equal("http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/student", amb.Audience[0].ID)
|
||||
assert.Equal("Schüler:in", amb.Audience[0].PrefLabel)
|
||||
assert.Equal("de", amb.Audience[0].InLanguage)
|
||||
|
||||
|
||||
assert.Equal("http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/teacher", amb.Audience[1].ID)
|
||||
assert.Equal("Lehrer:in", amb.Audience[1].PrefLabel)
|
||||
assert.Equal("de", amb.Audience[1].InLanguage)
|
||||
|
|
@ -408,25 +440,29 @@ func TestNostrToAMB_Audience(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Teaches(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"teaches", "http://awesome-skills.org/1", "Zuhören", "de"},
|
||||
{"teaches", "http://awesome-skills.org/2", "Sprechen", "de"},
|
||||
{"teaches:id", "http://awesome-skills.org/1"},
|
||||
{"teaches:prefLabel", "Zuhören"},
|
||||
{"teaches:inLanguage", "de"},
|
||||
{"teaches:id", "http://awesome-skills.org/2"},
|
||||
{"teaches:prefLabel", "Sprechen"},
|
||||
{"teaches:inLanguage", "de"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.Teaches))
|
||||
|
||||
|
||||
assert.Equal("http://awesome-skills.org/1", amb.Teaches[0].ID)
|
||||
assert.Equal("Zuhören", amb.Teaches[0].PrefLabel)
|
||||
assert.Equal("de", amb.Teaches[0].InLanguage)
|
||||
|
||||
|
||||
assert.Equal("http://awesome-skills.org/2", amb.Teaches[1].ID)
|
||||
assert.Equal("Sprechen", amb.Teaches[1].PrefLabel)
|
||||
assert.Equal("de", amb.Teaches[1].InLanguage)
|
||||
|
|
@ -434,25 +470,29 @@ func TestNostrToAMB_Teaches(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Assesses(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"assesses", "http://awesome-skills.org/1", "Hörverständnis", "de"},
|
||||
{"assesses", "http://awesome-skills.org/2", "Grammatik", "de"},
|
||||
{"assesses:id", "http://awesome-skills.org/1"},
|
||||
{"assesses:prefLabel", "Hörverständnis"},
|
||||
{"assesses:inLanguage", "de"},
|
||||
{"assesses:id", "http://awesome-skills.org/2"},
|
||||
{"assesses:prefLabel", "Grammatik"},
|
||||
{"assesses:inLanguage", "de"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.Assesses))
|
||||
|
||||
|
||||
assert.Equal("http://awesome-skills.org/1", amb.Assesses[0].ID)
|
||||
assert.Equal("Hörverständnis", amb.Assesses[0].PrefLabel)
|
||||
assert.Equal("de", amb.Assesses[0].InLanguage)
|
||||
|
||||
|
||||
assert.Equal("http://awesome-skills.org/2", amb.Assesses[1].ID)
|
||||
assert.Equal("Grammatik", amb.Assesses[1].PrefLabel)
|
||||
assert.Equal("de", amb.Assesses[1].InLanguage)
|
||||
|
|
@ -460,25 +500,29 @@ func TestNostrToAMB_Assesses(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_CompetencyRequired(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"competencyRequired", "http://awesome-skills.org/1", "Basisvokabular", "de"},
|
||||
{"competencyRequired", "http://awesome-skills.org/2", "Grundkenntnisse", "de"},
|
||||
{"competencyRequired:id", "http://awesome-skills.org/1"},
|
||||
{"competencyRequired:prefLabel", "Basisvokabular"},
|
||||
{"competencyRequired:inLanguage", "de"},
|
||||
{"competencyRequired:id", "http://awesome-skills.org/2"},
|
||||
{"competencyRequired:prefLabel", "Grundkenntnisse"},
|
||||
{"competencyRequired:inLanguage", "de"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.CompetencyRequired))
|
||||
|
||||
|
||||
assert.Equal("http://awesome-skills.org/1", amb.CompetencyRequired[0].ID)
|
||||
assert.Equal("Basisvokabular", amb.CompetencyRequired[0].PrefLabel)
|
||||
assert.Equal("de", amb.CompetencyRequired[0].InLanguage)
|
||||
|
||||
|
||||
assert.Equal("http://awesome-skills.org/2", amb.CompetencyRequired[1].ID)
|
||||
assert.Equal("Grundkenntnisse", amb.CompetencyRequired[1].PrefLabel)
|
||||
assert.Equal("de", amb.CompetencyRequired[1].InLanguage)
|
||||
|
|
@ -486,25 +530,29 @@ func TestNostrToAMB_CompetencyRequired(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_EducationalLevel(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"educationalLevel", "https://w3id.org/kim/educationalLevel/level_2", "Sekundarstufe 1", "de"},
|
||||
{"educationalLevel", "https://w3id.org/kim/educationalLevel/level_3", "Sekundarstufe 2", "de"},
|
||||
{"educationalLevel:id", "https://w3id.org/kim/educationalLevel/level_2"},
|
||||
{"educationalLevel:prefLabel", "Sekundarstufe 1"},
|
||||
{"educationalLevel:inLanguage", "de"},
|
||||
{"educationalLevel:id", "https://w3id.org/kim/educationalLevel/level_3"},
|
||||
{"educationalLevel:prefLabel", "Sekundarstufe 2"},
|
||||
{"educationalLevel:inLanguage", "de"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.EducationalLevel))
|
||||
|
||||
|
||||
assert.Equal("https://w3id.org/kim/educationalLevel/level_2", amb.EducationalLevel[0].ID)
|
||||
assert.Equal("Sekundarstufe 1", amb.EducationalLevel[0].PrefLabel)
|
||||
assert.Equal("de", amb.EducationalLevel[0].InLanguage)
|
||||
|
||||
|
||||
assert.Equal("https://w3id.org/kim/educationalLevel/level_3", amb.EducationalLevel[1].ID)
|
||||
assert.Equal("Sekundarstufe 2", amb.EducationalLevel[1].PrefLabel)
|
||||
assert.Equal("de", amb.EducationalLevel[1].InLanguage)
|
||||
|
|
@ -512,18 +560,20 @@ func TestNostrToAMB_EducationalLevel(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_InteractivityType(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"interactivityType", "http://purl.org/dcx/lrmi-vocabs/interactivityType/active", "aktiv", "de"},
|
||||
{"interactivityType:id", "http://purl.org/dcx/lrmi-vocabs/interactivityType/active"},
|
||||
{"interactivityType:prefLabel", "aktiv"},
|
||||
{"interactivityType:inLanguage", "de"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.NotNil(amb.InteractivityType)
|
||||
assert.Equal("http://purl.org/dcx/lrmi-vocabs/interactivityType/active", amb.InteractivityType.ID)
|
||||
assert.Equal("aktiv", amb.InteractivityType.PrefLabel)
|
||||
|
|
@ -532,18 +582,19 @@ func TestNostrToAMB_InteractivityType(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_IsBasedOn(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"isBasedOn", "http://an-awesome-resource.org", "Französisch I"},
|
||||
{"isBasedOn:id", "http://an-awesome-resource.org"},
|
||||
{"isBasedOn:name", "Französisch I"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(1, len(amb.IsBasedOn))
|
||||
assert.Equal("http://an-awesome-resource.org", amb.IsBasedOn[0].ID)
|
||||
assert.Equal("Französisch I", amb.IsBasedOn[0].Name)
|
||||
|
|
@ -551,18 +602,20 @@ func TestNostrToAMB_IsBasedOn(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_IsPartOf(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"isPartOf", "http://whole.org", "Whole", "PresentationDigitalDocument"},
|
||||
{"isPartOf:id", "http://whole.org"},
|
||||
{"isPartOf:name", "Whole"},
|
||||
{"isPartOf:type", "PresentationDigitalDocument"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(1, len(amb.IsPartOf))
|
||||
assert.Equal("http://whole.org", amb.IsPartOf[0].ID)
|
||||
assert.Equal("Whole", amb.IsPartOf[0].Name)
|
||||
|
|
@ -571,24 +624,28 @@ func TestNostrToAMB_IsPartOf(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_HasPart(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"hasPart", "http://part1.org", "Part 1", "LearningResource"},
|
||||
{"hasPart", "http://part2.org", "Part 2", "LearningResource"},
|
||||
{"hasPart:id", "http://part1.org"},
|
||||
{"hasPart:name", "Part 1"},
|
||||
{"hasPart:type", "LearningResource"},
|
||||
{"hasPart:id", "http://part2.org"},
|
||||
{"hasPart:name", "Part 2"},
|
||||
{"hasPart:type", "LearningResource"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(2, len(amb.HasPart))
|
||||
assert.Equal("http://part1.org", amb.HasPart[0].ID)
|
||||
assert.Equal("Part 1", amb.HasPart[0].Name)
|
||||
assert.Equal("LearningResource", amb.HasPart[0].Type)
|
||||
|
||||
|
||||
assert.Equal("http://part2.org", amb.HasPart[1].ID)
|
||||
assert.Equal("Part 2", amb.HasPart[1].Name)
|
||||
assert.Equal("LearningResource", amb.HasPart[1].Type)
|
||||
|
|
@ -596,42 +653,47 @@ func TestNostrToAMB_HasPart(t *testing.T) {
|
|||
|
||||
func TestNostrToAMB_Duration(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"duration", "PT30M"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal("PT30M", amb.Duration)
|
||||
}
|
||||
|
||||
func TestNostrToAMB_Trailer(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
||||
tags := nostr.Tags{
|
||||
{"d", "test-resource-id"},
|
||||
{"trailer", "https://example.com/video.mp4", "Video", "video/mp4", "10MB", "abc123", "https://example.com/embed", "1Mbps"},
|
||||
{"trailer:contentUrl", "https://example.com/video.mp4"},
|
||||
{"trailer:type", "VideoObject"},
|
||||
{"trailer:encodingFormat", "video/mp4"},
|
||||
{"trailer:contentSize", "10MB"},
|
||||
{"trailer:sha256", "abc123"},
|
||||
{"trailer:embedUrl", "https://example.com/embed"},
|
||||
{"trailer:bitrate", "1Mbps"},
|
||||
}
|
||||
event := createTestEvent(tags)
|
||||
|
||||
|
||||
amb, err := NostrToAMB(event)
|
||||
|
||||
|
||||
assert.NoError(err)
|
||||
assert.NotNil(amb)
|
||||
|
||||
|
||||
assert.Equal(1, len(amb.Trailer))
|
||||
assert.Equal("https://example.com/video.mp4", amb.Trailer[0].ContentUrl)
|
||||
assert.Equal("Video", amb.Trailer[0].Type)
|
||||
assert.Equal("VideoObject", amb.Trailer[0].Type)
|
||||
assert.Equal("video/mp4", amb.Trailer[0].EncodingFormat)
|
||||
assert.Equal("10MB", amb.Trailer[0].ContentSize)
|
||||
assert.Equal("abc123", amb.Trailer[0].Sha256)
|
||||
assert.Equal("https://example.com/embed", amb.Trailer[0].EmbedUrl)
|
||||
assert.Equal("1Mbps", amb.Trailer[0].Bitrate)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,17 +77,17 @@ type Audience struct {
|
|||
|
||||
// Teaches represents what the content teaches
|
||||
type Teaches struct {
|
||||
ControlledVocabulary
|
||||
ControlledVocabulary
|
||||
}
|
||||
|
||||
// Assesses represents what the content assesses
|
||||
type Assesses struct {
|
||||
ControlledVocabulary
|
||||
ControlledVocabulary
|
||||
}
|
||||
|
||||
// CompetencyRequired represents required competencies
|
||||
type CompetencyRequired struct {
|
||||
ControlledVocabulary
|
||||
ControlledVocabulary
|
||||
}
|
||||
|
||||
// EducationalLevel represents the educational level
|
||||
|
|
@ -102,7 +102,7 @@ type InteractivityType struct {
|
|||
|
||||
// IsBasedOn represents a reference to source material
|
||||
type IsBasedOn struct {
|
||||
ID string `json:"id"`
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Creator *Creator `json:"creator,omitempty"`
|
||||
|
|
@ -135,6 +135,41 @@ type License struct {
|
|||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// MainEntityProvider represents the provider of a web page
|
||||
type MainEntityProvider struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// MainEntityOfPage represents meta-metadata about web pages
|
||||
type MainEntityOfPage struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Provider *MainEntityProvider `json:"provider,omitempty"`
|
||||
DateCreated string `json:"dateCreated,omitempty"`
|
||||
DateModified string `json:"dateModified,omitempty"`
|
||||
}
|
||||
|
||||
// Encoding represents a media encoding (MediaObject)
|
||||
type Encoding struct {
|
||||
Type string `json:"type"`
|
||||
ContentUrl string `json:"contentUrl,omitempty"`
|
||||
EmbedUrl string `json:"embedUrl,omitempty"`
|
||||
EncodingFormat string `json:"encodingFormat,omitempty"`
|
||||
ContentSize string `json:"contentSize,omitempty"`
|
||||
Sha256 string `json:"sha256,omitempty"`
|
||||
Bitrate string `json:"bitrate,omitempty"`
|
||||
}
|
||||
|
||||
// Caption represents a caption/subtitle file (MediaObject)
|
||||
type Caption struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
EncodingFormat string `json:"encodingFormat,omitempty"`
|
||||
InLanguage string `json:"inLanguage,omitempty"`
|
||||
}
|
||||
|
||||
// NostrMetadata contains Nostr-specific metadata
|
||||
type NostrMetadata struct {
|
||||
EventID string `json:"eventID"`
|
||||
|
|
@ -190,9 +225,12 @@ type AMBMetadata struct {
|
|||
HasPart []*HasPart `json:"hasPart,omitempty"`
|
||||
|
||||
// Technical
|
||||
Duration string `json:"duration,omitempty"`
|
||||
// TODO Encoding ``
|
||||
// TODO Caption
|
||||
Duration string `json:"duration,omitempty"`
|
||||
Encoding []*Encoding `json:"encoding,omitempty"`
|
||||
Caption []*Caption `json:"caption,omitempty"`
|
||||
|
||||
// Meta-Metadata
|
||||
MainEntityOfPage []*MainEntityOfPage `json:"mainEntityOfPage,omitempty"`
|
||||
|
||||
// Nostr integration
|
||||
NostrMetadata `json:",inline"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue