Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to add details for mocking metastore variables #46

Open
prestonlewis opened this issue Apr 16, 2021 · 0 comments
Open

Request to add details for mocking metastore variables #46

prestonlewis opened this issue Apr 16, 2021 · 0 comments

Comments

@prestonlewis
Copy link

prestonlewis commented Apr 16, 2021

Hi team, the request is to add best practice(s) around mocking metastore variables for use in unit tests. I've been able to pull together the following code in my code but curious if you have other/better approaches for mocking out Variables for use in pytest or other unit test frameworks. Thanks.

from airflow.models.variable import Variable

def test_dummy(monkeypatch):
  def mock_get(*args, **kwargs):
    mocked_dict = { "dummy_key1":"dummy_val1","dummy_key2":"dummy_val2"}  
    return mocked_dict.get(args[0])

  monkeypatch.setattr(Variable,"get",mock_get)

  dummy_var = Variable.get("dummy_key1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant