def test_traffic(monkeypatch): mock_patch = MagicMock() mock_patch.return_value = FakeResponse(200, '["stack1","stack2"]') monkeypatch.setattr('requests.patch', mock_patch) lizzy = Lizzy('https://lizzy.example', '7E5770K3N') lizzy.traffic('574CC', 42) header = make_header('7E5770K3N') mock_patch.assert_called_once_with( 'https://lizzy.example/api/stacks/574CC', headers=header, data=None, json={"new_traffic": 42}, verify=False) # call with region payload mock_patch.reset_mock() lizzy = Lizzy('https://lizzy.example', '7E5770K3N') lizzy.traffic('574CC', 42, region='ab-foo-7') header = make_header('7E5770K3N') mock_patch.assert_called_once_with( 'https://lizzy.example/api/stacks/574CC', headers=header, data=None, json={ 'new_traffic': 42, 'region': 'ab-foo-7' }, verify=False)
def test_traffic(monkeypatch): mock_patch = MagicMock() mock_patch.return_value = FakeResponse(200, '["stack1","stack2"]') monkeypatch.setattr('requests.patch', mock_patch) lizzy = Lizzy('https://lizzy.example', '7E5770K3N') lizzy.traffic('574CC', 42) header = make_header('7E5770K3N') mock_patch.assert_called_once_with('https://lizzy.example/api/stacks/574CC', headers=header, data=None, json={"new_traffic": 42}, verify=False) # call with region payload mock_patch.reset_mock() lizzy = Lizzy('https://lizzy.example', '7E5770K3N') lizzy.traffic('574CC', 42, region='ab-foo-7') header = make_header('7E5770K3N') mock_patch.assert_called_once_with('https://lizzy.example/api/stacks/574CC', headers=header, data=None, json={'new_traffic': 42, 'region': 'ab-foo-7'}, verify=False)
def test_traffic(monkeypatch): mock_patch = MagicMock() mock_patch.return_value = FakeResponse(200, '["stack1","stack2"]') monkeypatch.setattr('requests.patch', mock_patch) lizzy = Lizzy('https://lizzy.example', '7E5770K3N') lizzy.traffic('574CC', 42) header = make_header('7E5770K3N') mock_patch.assert_called_once_with('https://lizzy.example/stacks/574CC', headers=header, data='{"new_traffic": 42}', verify=False)
def test_traffic(monkeypatch): mock_patch = MagicMock() mock_patch.return_value = FakeResponse(200, '["stack1","stack2"]') monkeypatch.setattr('requests.patch', mock_patch) lizzy = Lizzy('https://lizzy.example', '7E5770K3N') lizzy.traffic('574CC', 42) header = make_header('7E5770K3N') mock_patch.assert_called_once_with('https://lizzy.example/stacks/574CC', headers=header, data='{"new_traffic": 42}', verify=False)