Skip to content

Commit

Permalink
update expected cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Jun 9, 2024
1 parent ac6443a commit df90baa
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 84 deletions.
6 changes: 4 additions & 2 deletions tests/data/expected_mkdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This page provides comprehensive information about the structure and components
ontology(Ontology)
test(Test) --> test2(Test2)
test(Test) --> ontology(Ontology)

click test "#test" "Go to Test"
click test2 "#test2" "Go to Test2"
click ontology "#ontology" "Go to Ontology"
Expand All @@ -35,9 +35,12 @@ __name__* `string`

- The name of the test.


__number__ `float`


- `Default`: 1.0

__test2__ [`list[Test2]`](#test2)


Expand All @@ -57,7 +60,6 @@ __number__ `float`
- `Minimum`: 0



## Enumerations

### Ontology
Expand Down
153 changes: 94 additions & 59 deletions tests/data/expected_python_dc.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,95 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Test",
"type": "object",
"properties": {
"name": {
"title": "name",
"description": "The name of the test.",
"term": "schema:hello",
"type": "string"
},
"number": {
"title": "number",
"term": "schema:one",
"type": "number"
},
"test2": {
"term": "schema:something",
"type": "array",
"items": {
"$ref": "#/definitions/Test2"
}
},
"ontology": {
"title": "ontology",
"$ref": "#/definitions/Ontology"
}
},
"definitions": {
"Ontology": {
"title": "Ontology",
"type": "string",
"enum": [
"https://www.evidenceontology.org/term/",
"https://amigo.geneontology.org/amigo/term/",
"http://semanticscience.org/resource/"
]
},
"Test2": {
"title": "Test2",
"type": "object",
"properties": {
"names": {
"title": "names",
"term": "schema:hello",
"type": "array",
"items": {
"type": "string"
}
},
"number": {
"title": "number",
"term": "schema:one",
"type": "number",
"minimum": 0.0
## This is a generated file. Do not modify it manually!

from __future__ import annotations
from dataclasses import dataclass, field
from dataclasses_json import config, dataclass_json
from typing import List, Optional
from enum import Enum
from uuid import uuid4
from datetime import date, datetime


@dataclass_json
@dataclass
class Test:
name: str
number: float = 1.0
test2: List[Test2] = field(default_factory=list)
ontology: Optional[Ontology] = None

# JSON-LD fields
id: str = field(
metadata=config(field_name="@id"),
default_factory=lambda: "tst:Test/" + str(uuid4())
)
__type__: list[str] = field(
metadata=config(field_name="@type"),
default_factory = lambda: [
"tst:Test",
],
)
__context__: dict[str, str | dict] = field(
metadata=config(field_name="@context"),
default_factory = lambda: {
"tst": "https://www.github.com/my/repo/",
"schema": "http://schema.org/",
"name": {
"@id": "schema:hello",
"@type": "@id",
},
"number": "schema:one",
"test2": "schema:something",
}
}
}
}
}
)


def add_to_test2(
self,
names: List[str]= [],
number: Optional[float]= None,
**kwargs,
):
params = {
"names": names,
"number": number
}

self.test2.append(
Test2(**params)
)

return self.test2[-1]


@dataclass_json
@dataclass
class Test2:
names: List[str] = field(default_factory=list)
number: Optional[float] = None

# JSON-LD fields
id: str = field(
metadata=config(field_name="@id"),
default_factory=lambda: "tst:Test2/" + str(uuid4())
)
__type__: list[str] = field(
metadata=config(field_name="@type"),
default_factory = lambda: [
"tst:Test2",
],
)
__context__: dict[str, str | dict] = field(
metadata=config(field_name="@context"),
default_factory = lambda: {
"tst": "https://www.github.com/my/repo/",
"schema": "http://schema.org/",
"names": "schema:hello",
"number": "schema:one",
}
)


class Ontology(Enum):
ECO = "https://www.evidenceontology.org/term/"
GO = "https://amigo.geneontology.org/amigo/term/"
SIO = "http://semanticscience.org/resource/"
13 changes: 6 additions & 7 deletions tests/data/expected_python_sdrdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Test(
)

number: Optional[float] = attr(
default=None,
default=1.0,
tag="number",
json_schema_extra=dict(term = "schema:one",)
)
Expand All @@ -43,16 +43,15 @@ class Test(

_repo: str = PrivateAttr(default="https://www.github.com/my/repo/")


def add_to_test2(
self,
names: List[str],
number: Optional[float],
names: List[str]= [],
number: Optional[float]= None,
**kwargs,
):
params = {

"names": names,
"names": names,
"number": number
}

Expand All @@ -62,6 +61,7 @@ def add_to_test2(

return self.test2[-1]


class Test2(
sdRDM.DataModel,
search_mode="unordered",
Expand All @@ -80,7 +80,6 @@ class Test2(

_repo: str = PrivateAttr(default="https://www.github.com/my/repo/")



class Ontology(Enum):
ECO = "https://www.evidenceontology.org/term/"
Expand Down
3 changes: 2 additions & 1 deletion tests/data/expected_sdrdm_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "name",
"multiple": false,
"is_id": false,
"is_id": true,
"dtypes": ["string"],
"docstring": "The name of the test.",
"options": [],
Expand All @@ -26,6 +26,7 @@
"options": [],
"term": "schema:one",
"required": false,
"default": 1.0,
"xml": {
"is_attr": true,
"name": "number"
Expand Down
9 changes: 2 additions & 7 deletions tests/data/expected_shacl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,37 @@
tst:TestShape
a sh:NodeShape ;
sh:targetClass md:Test ;

sh:property [
sh:path schema:hello ;
sh:datatype xsd:string ;
sh:minCount 1 ;
sh:maxCount 1 ;

];
sh:property [
sh:path schema:one ;
sh:datatype xsd:double ;
sh:minCount 0 ;
sh:maxCount 1 ;

];
sh:property [
sh:path schema:something ;
sh:node md:Test2Shape ;
sh:minCount 0 ;

];

tst:Test2Shape
a sh:NodeShape ;
sh:targetClass md:Test2 ;

sh:property [
sh:path schema:hello ;
sh:datatype xsd:string ;
sh:minCount 0 ;

];
sh:property [
sh:path schema:one ;
sh:datatype xsd:double ;
sh:minCount 0 ;
sh:maxCount 1 ;

].
23 changes: 15 additions & 8 deletions tests/data/expected_xml_schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,38 @@
<!-- Roots -->
<xs:element name="Test" type="TestType"/>
<xs:element name="Test2" type="Test2Type"/>

<!-- Test Definition -->
<xs:complexType name="TestType">
<xs:sequence>
<xs:element name="test2">
<xs:complexType>
<xs:sequence>
<xs:element name="Test2" type="Test2Type" maxOccurs="unbounded"/>
<xs:element name="Test2" type="Test2Type" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ontology" type="OntologyType" />
<xs:element name="ontology" type="OntologyType"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="number" type="xs:float" />

<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
The name of the test.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="number" type="xs:float" default="1.0"/>
</xs:complexType>

<!-- Test2 Definition -->
<xs:complexType name="Test2Type">
<xs:sequence>
<xs:element name="names" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="number" type="xs:float" />
<xs:attribute name="number" type="xs:float"/>
</xs:complexType>

<!-- Enum Ontology Definition -->
<xs:simpleType name="OntologyType">
<xs:restriction base="xs:string">
Expand Down
1 change: 1 addition & 0 deletions tests/data/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ nsmap:
- Type: float
- Term: schema:one
- XML: @number
- Default: 1.0
- test2
- Type: [Test2](#test2)[]
- Term: schema:something
Expand Down

0 comments on commit df90baa

Please sign in to comment.