-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "neutron_understack: convert to poetry"
This reverts commits 3f0e9f8 and b4961f4 These changes have already been implemented in: #251 #253 Both of the PRs solve the same problem, so I don't need to solve it here again. It was initially fixed only because I was not aware of the other PRs. Reverting instead of dropping these commits, because they have been referenced externally in the comments.
- Loading branch information
Showing
6 changed files
with
84 additions
and
2,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 19 additions & 38 deletions
57
python/neutron-understack/neutron_understack/tests/test_neutron_understack_mech.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,37 @@ | ||
import builtins | ||
import json | ||
import pathlib | ||
from dataclasses import dataclass | ||
from unittest.mock import MagicMock, patch | ||
|
||
from unittest.mock import patch, MagicMock | ||
import pytest | ||
from neutron_understack.argo.workflows import ArgoClient | ||
|
||
from neutron_understack.neutron_understack_mech import UnderstackDriver | ||
|
||
# TODO: I am not sure how we run tests in this project. | ||
|
||
@dataclass | ||
class ContextDouble: | ||
current: dict | ||
current: dict | ||
|
||
|
||
def mock_context_data(filename): | ||
ref = pathlib.Path(__file__).parent / "fixtures" / filename | ||
def mock_context_data(file): | ||
ref = pathlib.Path(__file__).joinpath(filename) | ||
with ref.open("r") as f: | ||
return ContextDouble(json.load(f)) | ||
|
||
@pytest.fixture | ||
def mock_kubernetes_token(): | ||
original_open = builtins.open | ||
with patch("builtins.open") as mock_open: | ||
|
||
def mock_open_function(file, *args, **kwargs): | ||
if file == "/run/secrets/kubernetes.io/serviceaccount/token": | ||
mock_file = MagicMock() | ||
mock_file.read.return_value = "abc" | ||
return mock_file | ||
return original_open(file, *args, **kwargs) | ||
|
||
mock_open.side_effect = mock_open_function | ||
yield mock_open | ||
|
||
|
||
@patch("neutron_understack.argo.workflows.ArgoClient.submit") | ||
def test_update_port_postcommit(mock_argo_client, mock_kubernetes_token): | ||
context_data = mock_context_data("neutron_update_port_postcommit.json") | ||
from neutron_understack.neutron_understack_mech import UnderstackDriver | ||
@patch('neutron_understack.argo.workflows.ArgoClient') | ||
def test_update_port_postcommit(mock_argo_client): | ||
context_data = mock_context_data( | ||
"fixtures/neutron_update_port_postcommit.json" | ||
) | ||
|
||
driver = UnderstackDriver() | ||
driver.update_port_postcommit(context_data) | ||
UnderstackDriver.update_port_postcommit(context_data) | ||
|
||
mock_argo_client.assert_called_once_with( | ||
template_name="undersync-device", | ||
entrypoint="trigger-undersync", | ||
parameters={ | ||
"interface_mac": "fa:16:3e:35:1c:3d", | ||
"device_uuid": "", | ||
"network_name": "tenant", | ||
"dry_run": True, | ||
"force": False, | ||
"interface_uuid": "e5d5cd73-ca9a-4b74-9d52-43188d0cdcaa", | ||
"device_uuid": "41d18c6a-5548-4ee9-926f-4e3ebf43153f", | ||
"network_name": "provisioning", | ||
"dry_run": false, | ||
"force": false, | ||
}, | ||
service_account="workflow", | ||
) | ||
mock_kubernetes_token.assert_called() |
Oops, something went wrong.