diff --git a/graph/graph_test.go b/graph/graph_test.go index 1833eaf..49b4e7d 100644 --- a/graph/graph_test.go +++ b/graph/graph_test.go @@ -23,6 +23,58 @@ func getReader() (io.Reader, error) { ) } +func TestGraphClassTerm(t *testing.T) { + r, err := getReader() + if err != nil { + t.Fatal(err) + } + g, err := BuildGraph(r) + if err != nil { + t.Fatal(err) + } + term := "SO_0000340" + if !g.ExistsTerm(NodeID(term)) { + t.Fatalf("unable to find term %s", term) + } + cht := g.GetTerm(NodeID(term)) + if cht.ID() != NodeID(term) { + t.Fatalf("did not match term %s with id %s", term, cht.ID()) + } + if cht.Label() != "chromosome" { + t.Fatalf("expected label chromosome does not match %s", cht.Label()) + } + if cht.RdfType() != "CLASS" { + t.Fatalf("expected type CLASS does not match %s", cht.RdfType()) + } + if cht.IRI() != "http://purl.obolibrary.org/obo/SO_0000340" { + t.Fatalf("did not match term %s with iri %s", term, cht.IRI()) + } + s := cht.Meta().Subsets() + if len(s) < 1 { + t.Fatal("expected subset metadata is absent") + } + if m, _ := regexp.MatchString("SOFA", s[0]); !m { + t.Fatalf("expected subset does not match %s", s[0]) + } + p := cht.Meta().BasicPropertyValues() + if len(p) < 1 { + t.Fatal("expected basic propertyvalue metadata is absent") + } + if p[0].Value() != "sequence" { + t.Fatalf("expected basic propertyvalue of sequence does not match %s", p[0].Value()) + } + if cht.Meta().Namespace() != "sequence" { + t.Fatalf("expected namespace of sequence does not match %s", cht.Meta().Namespace()) + } + cm := cht.Meta().Comments() + if len(cm) < 1 { + t.Fatal("expected comment is absent") + } + if m, _ := regexp.MatchString("MGED", cm[0]); !m { + t.Fatalf("expected comment does not match %s", cm[0]) + } +} + func TestGraphPropertyTerm(t *testing.T) { r, err := getReader() if err != nil {