Refactor python tests

  • Posted:
  • Proposals: 4
  • Remote
  • #664289
  • Expired
Abdullah Al M.Mariusz K.Maksym S.Lucian D. have already sent a proposal.
  • 2


Experience Level: Intermediate
Estimated Job duration: 1 day or less
Small trial python job potentially leading to more work. Updated Tuesday 20th following feedback.

## Brief background:
I generated some Python tests, now they need refactoring; I'm not a pythonista so the 3 simple unit test python files are hacked together from an example in a way that works. I would like to have these refactored so that instead of 3 unit test python files I would have 1 single unit test python file.

## Situation:
These tests are testing a plugin for a framework called 'Cloudify' (; Cloudify uses a file called a 'blueprint' to execute certain actions.

The structure of each unit test file is:
- setup method (references the test-specific 'blueprint file')
- test_[method-under-test name] (this mocks the specific plugin action it's testing and executes the 'blueprint', asserting the result)

There are (now) 3 methods available within the plugin: 1. deploy_vm, 2. install_adds & 3. install_mssql

Each of these files has it's own unit test file, however is actually testing one single method within the plugin.

So unit test also has a separate file which is related to the particular method; i.e. deploy_vm has deploy_vm.yml

Essentially each test does this:
1. Initialise Cloudify with the appropriate blueprint config file
2. Mock out the particular method-under-test
3. Order Cloudify to execute the blueprint
4. Compare result of Cloudify execution against expected results

A sample of _one_ of these test cases has been attached to this job. Each of the other test cases is nearly identical in form _apart from_ the assertions that each test case makes (but I don't expect these need changing).

## Problem
3 separate test files for 3 actions which have very few sub-cases seems like too much; I feel that this could be refactored into a single test file. It could be exceedingly simple or, possibly, Cloudify causes some problems. I currently have no clue. That's where you come in!

## Required solution

The requirement here is that an elegant solution be found in refactoring the tests together. The minimum requirement is that the 3 unit test cases become 1 single test case.

## Frameworks / technologies in use:

- Python
- unittest
- mock
- tox
- Cloudify (no prior knowledge required ... I hope and tox will ensure the dependencies are present)

At present the frameworks are not negotiate-able (but might be in the future assuming this job goes well).

New Proposal

Create an account now and send a proposal now to get this job.

Sign up

Clarification Board Ask a Question

    There are no clarification messages.