Skip to content

Commit

Permalink
add native python tests ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Apr 2, 2024
1 parent 2a999e8 commit fc8f63e
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 18 deletions.
6 changes: 6 additions & 0 deletions ARCtrl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.Spreadsheet.Tests",
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.FileSystem.Tests", "tests\FileSystem\ARCtrl.FileSystem.Tests.fsproj", "{704935A5-68F2-4070-8A55-AFF8F66ACAD6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{501F6D1E-6300-4CA4-8E61-3523BCF4D533}"
ProjectSection(SolutionItems) = preProject
tests\Python\test_index.py = tests\Python\test_index.py
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -146,6 +151,7 @@ Global
{9E1FF103-B5BD-44B6-B839-0E1FED2C49EC} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38}
{03F4E6D0-CFE7-44A6-994B-778B3DF6532C} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38}
{704935A5-68F2-4070-8A55-AFF8F66ACAD6} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38}
{501F6D1E-6300-4CA4-8E61-3523BCF4D533} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1E354DE6-99BA-421E-9EF8-E808B855A85F}
Expand Down
29 changes: 14 additions & 15 deletions build/GenerateIndexPy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@ let classes =
"__future__", "annotations"
"collections.abc", "Callable"
"typing", "Any"
".ISA.ISA.JsonTypes.comment", "Comment"
".ISA.ISA.JsonTypes.ontology_annotation","OntologyAnnotation";
".ISA.ISA.JsonTypes.person", "Person";
".ISA.ISA.JsonTypes.publication", "Publication";
".ISA.ISA.ArcTypes.composite_header", "IOType"
".ISA.ISA.ArcTypes.composite_header", "CompositeHeader";
".ISA.ISA.ArcTypes.composite_cell", "CompositeCell"
".ISA.ISA.ArcTypes.composite_column", "CompositeColumn"
".ISA.ISA.ArcTypes.arc_table", "ArcTable"
".ISA.ISA.ArcTypes.arc_types", "ArcAssay";
".ISA.ISA.ArcTypes.arc_types", "ArcStudy";
".ISA.ISA.ArcTypes.arc_types", "ArcInvestigation";
".Templates.template", "Template"
".Templates.templates", "Templates"
".Templates.template", "Organisation"
".Core.comment", "Comment"
".Core.ontology_annotation","OntologyAnnotation";
".Core.person", "Person";
".Core.publication", "Publication";
".Core.Table.composite_header", "IOType"
".Core.Table.composite_header", "CompositeHeader";
".Core.Table.composite_cell", "CompositeCell"
".Core.Table.composite_column", "CompositeColumn"
".Core.Table.arc_table", "ArcTable"
".Core.arc_types", "ArcAssay";
".Core.arc_types", "ArcStudy";
".Core.arc_types", "ArcInvestigation";
".Core.template", "Template"
".json", "JsonController"
".arc","ARC"
|]

Expand Down
6 changes: 6 additions & 0 deletions build/ProjectInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ let jsTestProjects =
"tests/JavaScript"
]

/// Native JS test paths
let pyTestProjects =
[
"tests/Python"
]

let solutionFile = $"{project}.sln"

let configuration = "Release"
Expand Down
11 changes: 10 additions & 1 deletion build/TestTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ module RunTests =
run node $"{path}/js/Main.js" ""
}

let runTestsPyNative = BuildTask.create "runTestsPyNative" [clean; build] {
Trace.traceImportant "Start native Python tests"
for path in ProjectInfo.pyTestProjects do
// transpile library for native access
run dotnet $"fable src/ARCtrl -o {path}/ARCtrl --lang python" ""
GenerateIndexPy.ARCtrl_generate($"{path}/ARCtrl")
run python $"-m pytest {path}" ""
}

let runTestsPy = BuildTask.create "runTestsPy" [clean; build] {
for path in ProjectInfo.testProjects do
//transpile py files from fsharp code
Expand All @@ -50,6 +59,6 @@ module RunTests =
|> Seq.iter dotnetRun
}

let runTests = BuildTask.create "RunTests" [clean; build; RunTests.runTestsJs; RunTests.runTestsJsNative; RunTests.runTestsPy; RunTests.runTestsDotnet] {
let runTests = BuildTask.create "RunTests" [clean; build; RunTests.runTestsJs; RunTests.runTestsJsNative; RunTests.runTestsPy; RunTests.runTestsPyNative; RunTests.runTestsDotnet] {
()
}
99 changes: 97 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ readme = "README.md"
python = "^3.10"
requests = "2.28.1"

[tool.poetry.group.dev.dependencies]
pytest = "^8.1.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file added tests/Python/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions tests/Python/test_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .ARCtrl.arctrl import OntologyAnnotation, JsonController, ArcInvestigation

class TestOntologyAnnotation:

def test_create(self):
oa = OntologyAnnotation("instrument model", "MS", "MS:1234567")
assert oa.NameText == "instrument model"

class TestInvestigation:

def test_json(self):
i = ArcInvestigation.init("My Investigation")
actual = JsonController.Investigation().to_json_string()(i)
expected = """{"Identifier":"My Investigation"}"""
assert actual == expected

0 comments on commit fc8f63e

Please sign in to comment.