vmware / vmware/pyvmomi

Unit testing - mocking objects

Open
#658 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

Hello,

I want to unit test my code that uses pyvmomi. I don't want it have any side effects or for it to make any requests. I don't really want to use replay tests for testing my own code either.

I'm having a hard time coming up with a way to mock this API. I'm looking at SoapStubAdapter class wondering whether I can just mock its InvokeMethod to not do anything except return what I want.

Of course, this leads to many more problems. Is there a way to do this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names SoapStubAdapter and InvokeMethod but no repository file or test. Start by locating those symbols and reviewing the replay tests and stub behavior mentioned in the report. Done would require a clearly scoped, side-effect-free testing approach and validation, but the issue does not define the expected API.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.