aristanetworks / ansible-cvp

Ansible modules for Arista CloudVision
http://cvp.avd.sh
Apache License 2.0
66 stars 61 forks source link

Change structure of Unittest lib #610

Closed sugetha24 closed 1 year ago

sugetha24 commented 1 year ago

Enhancement summary

Change the way we mock cvpApi() Something like this

@pytest.fixture
def mock_cvpClient():
    """
    mock_cvprac - mocks cvprac classes/objects
    """
    # mocked cvpClient object
    mock_cvpClient = create_autospec(CvpClient)
    mock_cvpClient.api = create_autospec(spec=CvpApi)
    mock_cvpClient.api.apply_image_to_element.side_effect = mockMagic.apply_image_to_element
    mock_cvpClient.api.get_image_bundle_by_name.side_effect = mockMagic.get_image_bundle_by_name
    return mock_cvpClient

This makes it easier to apply side_effect to any Cvprac functions on the fly

Which component of AVD is impacted

other

Use case example

NA

Describe the solution you'd like

NA

Describe alternatives you've considered

No response

Additional context

No response

Code of Conduct

sugetha24 commented 1 year ago

PR for ref: https://github.com/aristanetworks/ansible-cvp/pull/572