PolySwarmPolySwarmPolySwarmPolySwarm
Go to PolySwarm
Home

Unit Testing Your Engine

Let's test the Clamav engine that we built in the previous stage. microengine-webhooks-py comes with some unit tests already built-in. The tests are quite simple, but give a good indication whether a FILE engine is working.

To run the tests, first open a Terminal with an activated Python virtual environment, the same virtual environment we created earlier. In that Terminal, run pytest at the root of the project directory, like this:

(psvenv) $ pytest -s

If you followed along with our instructions in the previous steps to build the Clamav engine, some tests should fail. At this point, we expect that the server tests worked just fine, but the scan tests failed. This is because we don't have a ClamAV service, also called clamd running to test against.

Let's stand up a ClamAV service using docker. So, run the following commands in a Terminal:

(psvenv) $ docker pull mkodockx/docker-clamav/
(psvenv) $ docker run -d -p "3310:3310" mkodockx/docker-clamav/

The default CLAMD_HOST and CLAMD_PORT will work. So, let's run pytest again. Now we expect all tests to pass. If they do not all pass, go back and double-check your work.


Next Steps

Next, let's run the local integration tests.

2024 © PolySwarm Pte. Ltd.