Commit 63057eb3 authored by Cage, Gregory's avatar Cage, Gregory
Browse files

Add initial testing for library

parent 76d57289
Loading
Loading
Loading
Loading
Loading

tests/conftest.py

0 → 100644
+23 −0
Original line number Diff line number Diff line
"""Config for testing."""

import os

import pytest
from bioblend.galaxy import GalaxyInstance

from nova.galaxy.nova import Nova

GALAXY_URL = os.environ.get("NOVA_GALAXY_TEST_GALAXY_URL, " "https://calvera-test.ornl.gov")
GALAXY_API_KEY = os.environ.get("NOVA_GALAXY_TEST_GALAXY_KEY")


@pytest.fixture
def nova_instance() -> Nova:
    nova = Nova(GALAXY_URL, GALAXY_API_KEY)
    return nova


@pytest.fixture
def galaxy_instance() -> GalaxyInstance:
    galaxy = GalaxyInstance(url=GALAXY_URL, key=GALAXY_API_KEY)
    return galaxy
+26 −0
Original line number Diff line number Diff line
"""Tests for data stores."""

from bioblend.galaxy import GalaxyInstance

from nova.galaxy.nova import Nova


def test_no_persist_store(nova_instance: Nova, galaxy_instance: GalaxyInstance) -> None:
    with nova_instance.connect() as connection:
        store = connection.create_data_store(name="nova_galaxy_testing")
        history = galaxy_instance.histories.get_histories(name=store.name)
        assert len(history) > 0
    history = galaxy_instance.histories.get_histories(name=store.history_id, deleted=False)
    assert len(history) < 1


def test_persist_store(nova_instance: Nova, galaxy_instance: GalaxyInstance) -> None:
    with nova_instance.connect() as connection:
        store = connection.create_data_store(name="nova_galaxy_testing")
        store.persist()
        history = galaxy_instance.histories.get_histories(name=store.name)
        assert len(history) > 0
    history = galaxy_instance.histories.get_histories(name=store.name, deleted=False)
    assert len(history) > 0
    # TODO: Can maybe do global cleanup
    galaxy_instance.histories.delete_history(history_id=history[0]["id"], purge=True)

tests/test_dataset.py

0 → 100644
+17 −0
Original line number Diff line number Diff line
"""Tests for datasets."""

from nova.galaxy.dataset import Dataset
from nova.galaxy.nova import Nova


def test_dataset_upload(nova_instance: Nova) -> None:
    with nova_instance.connect() as connection:
        store = connection.create_data_store(name="nova_galaxy_testing")
        input = Dataset("tests/test_files/test_text_file.txt")
        input.upload(store)
        assert input.get_content() is not None


def test_dataset_collection_upload(nova_instance: Nova) -> None:
    # TODO: Dataset collection uploading needs to be implemented
    pass
+25 −0
Original line number Diff line number Diff line
%% Cell type:markdown id: tags:

# Welcome to the interactive Galaxy Jupyter Notebook (ORNL version).

%% Cell type:markdown id: tags:

If you provided input data when you started the tool, you can access it in __./data__ folder. The output data should be placed in __./outputs__ folder. If you selected output
type - _Dataset Collection_, the whole folder content will be stored in your history as a Galaxy dataset collection; if you selected _Single Dataset_ - __./outputs__ should contain one file (if there are more, the first file will be selected by alphabetical order, the rest will be erased). The tool will exit with error if you selected a _Single Dataset_ and did not put anything into __./outputs__.

<span style="color:red">__Note:__ To exit properly and send outputs to Galaxy, save this notebook (click the “save” icon or File->Save Notebook) and shut it down (click File->Shut Down).
</span>

More information can be found in the [documentation](https://calvera.ornl.gov/docs/science/generic/howtows/jupyter/).

%% Cell type:code id: tags:

``` python
with open("outputs/test.txt", "w") as file:
    file.write("this is a test")
```

%% Cell type:code id: tags:

``` python
```
+1 −0
Original line number Diff line number Diff line
Text file for testing.
Loading