Skip to content

conftest#

mock_qvain_dataset_with_files_request#

Source code in tests/behave/features/qvain/conftest.py
@pytest.fixture
def mock_qvain_dataset_with_files_request(qvain_user, frozen_files_in_ida, mock_request):
    def _mock_qvain_dataset_with_files_request(status_code, published):
        request = mock_request(status_code)
        request.published = published
        request.user = qvain_user
        request.files = frozen_files_in_ida
        return request

    yield _mock_qvain_dataset_with_files_request
    raise NotImplementedError

frozen_files_in_ida#

When files are frozen in IDA, new File Model Objects are created for the IDA-project in Metax

Source code in tests/behave/features/qvain/conftest.py
@pytest.fixture
@given("user has frozen files in IDA")
def frozen_files_in_ida():
    """When files are frozen in IDA, new File Model Objects are created for the IDA-project in Metax"""
    files = FileFactory.create_batch(3, frozen=timezone.now())
    return files

qvain_publish_request#

Makes API-Request to Dataset API with Dataset information

Returns: API Request Response for Qvain

Source code in tests/behave/features/qvain/conftest.py
@pytest.fixture
@when("user publishes a new dataset in Qvain")
def qvain_publish_request(mock_qvain_dataset_with_files_request):
    """Makes API-Request to Dataset API with Dataset information

    Returns: API Request Response for Qvain

    """
    request = mock_qvain_dataset_with_files_request(status_code=201, published=True)
    yield request
    raise NotImplementedError

published_dataset#

TODO
  • Research Dataset should be generated in the qvain_publish_request step instead of using Factory Class
  • This step should do an assert instead of being a fixture

Parameters:

Name Type Description Default
qvain_publish_request

Request object from Qvain

required
ida_data_catalog

IDA DataCatalog

required

Returns: Research Dataset object

Source code in tests/behave/features/qvain/conftest.py
@pytest.fixture
@when("new published dataset is created in IDA data-catalog with persistent identifier")
def published_dataset(ida_data_catalog: DataCatalog, qvain_publish_request, faker) -> Dataset:
    """

    TODO:
        * Research Dataset should be generated in the qvain_publish_request step instead of using Factory Class
        * This step should do an assert instead of being a fixture

    Args:
        qvain_publish_request (): Request object from Qvain
        ida_data_catalog (): IDA DataCatalog

    Returns: Research Dataset object

    """

    dataset = DatasetFactory(
        data_catalog=ida_data_catalog,
        issued=timezone.now().date(),
        persistent_identifier=faker.uuid4(),
    )
    yield dataset
    raise NotImplementedError

qvain_user#

Source code in tests/behave/features/qvain/conftest.py
@pytest.fixture
def qvain_user(faker):
    user = MetaxUserFactory(username="test_user", password=faker.password())
    return user