Running API and UI tests

Yoda uses pytest for API and UI tests.

Running tests on the allinone VM

In order to run the tests on the Vagrant-based development environment, the allinone (default) Vagrant configuration automatically mounts the /etc/irods/yoda-ruleset directory in the VM on the ./test directory.

  1. To run the UI tests you need Firefox 102 ESR or later.
  2. Ensure that you have geckodriver 0.34.0 installed for running the UI tests.
  3. Create the development VM using Vagrant:
    vagrant box update && vagrant up
    
  4. Deploy the VM.
    ansible-playbook -i environments/development/allinone playbook.yml -D
    

On a Windows host first SSH into the Ansible controller virtual machine (skip this step on GNU/Linux or macOS):

vagrant ssh controller
cd ~/yoda
  1. Deploy the test data on the VM:
    ansible-playbook -i environments/development/allinone test.yml -D
    
  2. Clone the yoda-ruleset repository and install the test dependencies
    git clone https://github.com/UtrechtUniversity/yoda-ruleset.git
    cd yoda-ruleset/tests
    python3 -m pip install -r requirements.txt
    
  3. Run the tests (in the yoda-ruleset/tests directory)
    test -d /tmp/cache || mkdir -p /tmp/cache
    python3 -m pytest -o cache_dir=/tmp/cache
    

Custom test options

The test suite accepts the following custom options:

  --datarequest         Run datarequest tests
  --deposit             Run deposit tests
  --intake              Run intake tests
  --archive             Run vault archive tests
  --sram                Run group SRAM tests
  --skip-ui             Skip UI tests
  --skip-api            Skip API tests
  --all                 Run all tests
  --environment=ENVIRONMENT
                        Specify configuration file
  --verbose-test        Print additional information for troubleshooting purposes

The default configuration files are located in directory tests/environments.

Option --all is incompatible with the --skip-ui and --skip-api options.

Testing against Datacite

By default, the development VM uses an internal mock Datacite service. If you want to test against a real Datacite environment, you will need to provide the Datacite server name and credentials when deploying the VM (step 4). For example:

ansible-playbook -i environments/development/allinone playbook.yml --extra-vars 'datacite_server=api.test.datacite.org datacite_username=MYUSERNAME datacite_password=MYPASSWORD' -D

Development

  • Tests are written with Pytest-BDD: https://pytest-bdd.readthedocs.io/en/latest/
  • UI tests use Splinter to automate browser actions: https://splinter.readthedocs.io/en/latest/index.html