Skip to content

Create unit tests for getopa.py #804

@mitchelbaker-cisa

Description

@mitchelbaker-cisa

Prerequisites

  • This issue has an informative and human-readable title.

💡 Summary

Create a new function, test_getopa.py, which will house the unit tests for the getopa.py function.

The test_getopa.py function should be stored inside of the scubagoggles/Testing/Python directory.

scubagoggles

  • Testing
    • Functional
    • Rego
    • Python
      • test_getopa.py

Motivation and context

This issue is in relation to epic #330

Implementation notes

We will use the pytest library for implementing unit tests and use a class-based approach for the file structure.

Class TestGetOpa

  • def test_getopa_raises_user_runtime_error(self, ...)
  • def test_download_opa_raises_error_on_invalid_version_string(self, ...)
  • def test_download_opa_raises_error_when_not_semantic_version(self, ...)
  • def test_opa_filespec_returns_expected_path_for_windows(self, ...)
  • def test_opa_filespec_returns_expected_path_for_linux(self, ...)
  • def test_opa_filespec_returns_expected_path_for_macos(self, ...)
  • def test_verify_opa_returns_true_for_valid_binary(self, ...)
  • def test_verify_opa_returns_false_for_invalid_binary(self, ...)

Then running the unit tests are as simple as:

# for all Python unit tests
pytest ./Testing/Python/

# for all unit tests for a given file
pytest ./Testing/Python/test_getopa.py

# for an individual unit test
pytest ./Testing/Python -k test_opa_filespec_returns_expected_path_for_windows

Acceptance criteria

  • The test_getopa.py function is added
  • TestGetOpa class is implemented with methods that test the required behavior for each function declared in getopa.py

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions