Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fast_start_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
set -eu

source /venv/bin/activate

pip install --no-cache --upgrade pip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class NeighborV4DeleteSuccessTestCase(NetworkApiTestCase):
fixtures_path.format('initial_ipv4.json'),
fixtures_path.format('initial_asn.json'),
fixtures_path.format('initial_route_map.json'),
fixtures_path.format('initial_peer_group.json'),
fixtures_path.format('initial_equipment.json'),
fixtures_path.format('initial_asn_equipment.json'),
fixtures_path.format('initial_ipv4_equipment.json'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def test_post_neighbor_v4_with_remotes_in_different_eqpts(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'RemoteIp id = 8 and RemoteAsn id = 7 '
u'belongs to different Equipments',
u'O ASN remoto (id: 7) não está associado a qualquer '
u'equipamento do IP (id: 8). ',
response.data['detail']
)

Expand All @@ -219,8 +219,9 @@ def test_post_neighbor_v4_with_peer_group_envs_diff_local_ip_env(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'LocalIp id = 9 and PeerGroup id = 4 '
u'belongs to different Environments',
u'Not allowed to configure BGP neighbor using this Peer Group. '
u'PeerGroup id = 4 is not mapped to the environment of '
u'LocalIp id = 9',
response.data['detail']
)

Expand All @@ -238,7 +239,8 @@ def test_post_neighbor_v4_duplicated(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'It already exists Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and RemoteIp id = 2',
u'Duplicated neighbor. A Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and '
u'RemoteIp id = 2 already exists',
response.data['detail']
)
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def test_put_neighbor_v4_with_remotes_in_different_eqpts(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'RemoteIp id = 8 and RemoteAsn id = 7 '
u'belongs to different Equipments',
u'O ASN remoto (id: 7) não está associado a qualquer '
u'equipamento do IP (id: 8). ',
response.data['detail']
)

Expand All @@ -235,8 +235,9 @@ def test_put_neighbor_v4_with_peer_group_envs_diff_local_ip_env(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'LocalIp id = 1 and PeerGroup id = 3 '
u'belongs to different Environments',
u'Not allowed to configure BGP neighbor using this Peer Group. '
u'PeerGroup id = 3 is not mapped to the environment of '
u'LocalIp id = 1',
response.data['detail']
)

Expand All @@ -254,7 +255,8 @@ def test_put_neighbor_v4_duplicated(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'It already exists Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and RemoteIp id = 2',
u'Duplicated neighbor. A Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and '
u'RemoteIp id = 2 already exists',
response.data['detail']
)
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def test_post_neighbor_v6_with_remotes_in_different_eqpts(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'RemoteIp id = 8 and RemoteAsn id = 7 '
u'belongs to different Equipments',
u'O ASN remoto (id: 7) não está associado a qualquer '
u'equipamento do IP (id: 8). ',
response.data['detail']
)

Expand All @@ -218,8 +218,9 @@ def test_post_neighbor_v6_with_peer_group_envs_diff_local_ip_env(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'LocalIp id = 1 and PeerGroup id = 3 '
u'belongs to different Environments',
u'Not allowed to configure BGP neighbor using this Peer Group. '
u'PeerGroup id = 3 is not mapped to the environment of '
u'LocalIp id = 1',
response.data['detail']
)

Expand All @@ -237,7 +238,8 @@ def test_post_neighbor_v6_duplicated(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'It already exists Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and RemoteIp id = 2',
u'Duplicated neighbor. A Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and '
u'RemoteIp id = 2 already exists',
response.data['detail']
)
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ def test_put_neighbor_v6_with_remotes_in_different_eqpts(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'RemoteIp id = 8 and RemoteAsn id = 7 '
u'belongs to different Equipments',
u'O ASN remoto (id: 7) não está associado a qualquer '
u'equipamento do IP (id: 8). ',
response.data['detail']
)

Expand All @@ -236,8 +236,9 @@ def test_put_neighbor_v6_with_peer_group_envs_diff_local_ip_env(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'LocalIp id = 9 and PeerGroup id = 3 '
u'belongs to different Environments',
u'Not allowed to configure BGP neighbor using this Peer Group. '
u'PeerGroup id = 3 is not mapped to the environment of '
u'LocalIp id = 9',
response.data['detail']
)

Expand All @@ -255,7 +256,8 @@ def test_put_neighbor_v6_duplicated(self):

self.compare_status(400, response.status_code)
self.compare_values(
u'It already exists Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and RemoteIp id = 2',
u'Duplicated neighbor. A Neighbor with LocalAsn id = 1, '
u'LocalIp id = 1, RemoteAsn id = 2 and '
u'RemoteIp id = 2 already exists',
response.data['detail']
)
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,15 @@ def setUp(self):
def tearDown(self):
pass

@patch('networkapi.api_network.facade.v3.utils.generate_config_file')
@patch('networkapi.plugins.factory.PluginFactory.factory')
def test_try_undeploy_netipv4(self, test_patch):
def test_try_undeploy_netipv4(self, test_patch, mock_gen_config):
"""Test of success to undeploy a Network IPv4."""

mock = MockPluginNetwork()
mock.status(True)
test_patch.return_value = mock
mock_gen_config.return_value = 'mock_config_file'

response = self.client.delete(
'/api/v3/networkv4/deploy/1/')
Expand Down Expand Up @@ -385,7 +387,7 @@ class NetworkIPv4ForceDeleteSuccessTestCase(NetworkApiTestCase):

def setUp(self):
self.client = APIClient()
self.user = Usuario.objects.get(user='test')
self.user = Usuario.objects.get(user='test_admin')
self.client.force_authenticate(user=self.user)

def tearDown(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ def setUp(self):
def tearDown(self):
pass

@patch('networkapi.api_network.facade.v3.utils.generate_config_file')
@patch('networkapi.plugins.factory.PluginFactory.factory')
def test_try_deploy_inactive_netipv4(self, test_patch):
def test_try_deploy_inactive_netipv4(self, test_patch, mock_gen_config):
"""Test of success to deploy a inactive NetworkIPv4."""

mock = MockPluginNetwork()
mock.status(True)
test_patch.return_value = mock
mock_gen_config.return_value = 'mock_config_file'

response = self.client.post(
'/api/v3/networkv4/deploy/3/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,15 @@ def setUp(self):
def tearDown(self):
pass

@patch('networkapi.api_network.facade.v3.utils.generate_config_file')
@patch('networkapi.plugins.factory.PluginFactory.factory')
def test_try_undeploy_netipv6(self, test_patch):
def test_try_undeploy_netipv6(self, test_patch, mock_gen_config):
"""Test of success to undeploy a Network IPv6."""

mock = MockPluginNetwork()
mock.status(True)
test_patch.return_value = mock
mock_gen_config.return_value = 'mock_config_file'

response = self.client.delete(
'/api/v3/networkv6/deploy/1/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,15 @@ def setUp(self):
def tearDown(self):
pass

@patch('networkapi.api_network.facade.v3.utils.generate_config_file')
@patch('networkapi.plugins.factory.PluginFactory.factory')
def test_try_deploy_inactive_netipv6(self, test_patch):
def test_try_deploy_inactive_netipv6(self, test_patch, mock_gen_config):
"""Test of success to deploy a inactive NetworkIPv6."""

mock = MockPluginNetwork()
mock.status(True)
test_patch.return_value = mock
mock_gen_config.return_value = 'mock_config_file'

url_post = '/api/v3/networkv6/deploy/3/'

Expand Down
2 changes: 1 addition & 1 deletion networkapi/api_rack/fixtures/initial_rack.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"id_sw1": 1,
"id_sw2": 2,
"id_ilo": 3,
"dcroom": 1
"dcroom": 2
}
}
]
2 changes: 1 addition & 1 deletion networkapi/api_rack/tests/fabric/test_fabric.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def setup():
call_command(
'loaddata',
'networkapi/system/fixtures/basic_variables.json',
'networkapi/system/fixtures/initial_variables.json',
'networkapi/usuario/fixtures/initial_usuario.json',
'networkapi/grupo/fixtures/initial_ugrupo.json',
'networkapi/usuario/fixtures/initial_usuariogrupo.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"mac_ilo": "3F:FF:FF:FF:FF:FF",
"mac_sw1": "1F:FF:FF:FF:FF:FF",
"mac_sw2": "2F:FF:FF:FF:FF:FF",
"nome": null,
"numero": null
"nome": "PUT10",
"numero": 10
}
}
4 changes: 2 additions & 2 deletions networkapi/api_rack/tests/rack/json/put_rack.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"mac_ilo": "3F:FF:FF:FF:FF:FF",
"mac_sw1": "1F:FF:FF:FF:FF:FF",
"mac_sw2": "2F:FF:FF:FF:FF:FF",
"nome": "PUT10",
"numero": 10
"name": "PUT10",
"number": 10
}
}
2 changes: 1 addition & 1 deletion networkapi/api_rack/tests/rack/test_rack.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def setup():
call_command(
'loaddata',
'networkapi/system/fixtures/basic_variables.json',
'networkapi/system/fixtures/initial_variables.json',
'networkapi/usuario/fixtures/initial_usuario.json',
'networkapi/grupo/fixtures/initial_ugrupo.json',
'networkapi/usuario/fixtures/initial_usuariogrupo.json',
Expand Down
12 changes: 11 additions & 1 deletion networkapi/api_vip_request/tests/sanity/sync/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json
import logging

from mock import patch

from django.core.management import call_command
from django.test.client import Client

Expand Down Expand Up @@ -33,12 +35,20 @@ class VipRequestPostTestCase(NetworkApiTestCase):

def setUp(self):
self.client = Client()
# Fix BooleanFields without defaults for SQLite compatibility
from networkapi.requisicaovips.models import RequisicaoVips
RequisicaoVips._meta.get_field('validado').default = False
RequisicaoVips._meta.get_field('vip_criado').default = False
RequisicaoVips._meta.get_field('filter_valid').default = False

def tearDown(self):
pass

def test_post_two_vips_success(self):
@patch('networkapi.plugins.factory.PluginFactory.factory')
@patch('networkapi.api_vip_request.syncs.new_to_old')
def test_post_two_vips_success(self, mock_new_to_old, mock_plugin_factory):
"""Test of success to post one vip."""
mock_plugin_factory.return_value.get_name_eqpt.return_value = 'VIP1_test_80'

name_file = 'api_vip_request/tests/sanity/json/post/test_vip_request_post_2_ports.json'

Expand Down
12 changes: 11 additions & 1 deletion networkapi/api_vip_request/tests/sanity/sync/test_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json
import logging

from mock import patch

from django.core.management import call_command
from django.test.client import Client

Expand Down Expand Up @@ -34,12 +36,20 @@ class VipRequestPutTestCase(NetworkApiTestCase):

def setUp(self):
self.client = Client()
# Fix BooleanFields without defaults for SQLite compatibility
from networkapi.requisicaovips.models import RequisicaoVips
RequisicaoVips._meta.get_field('validado').default = False
RequisicaoVips._meta.get_field('vip_criado').default = False
RequisicaoVips._meta.get_field('filter_valid').default = False

def tearDown(self):
pass

def test_put_two_vips_success(self):
@patch('networkapi.plugins.factory.PluginFactory.factory')
@patch('networkapi.api_vip_request.syncs.new_to_old')
def test_put_two_vips_success(self, mock_new_to_old, mock_plugin_factory):
"""Test of success to put two vips."""
mock_plugin_factory.return_value.get_name_eqpt.return_value = 'VIP1_test_80'

name_file = 'api_vip_request/tests/sanity/json/put/test_vip_request_put_two.json'

Expand Down
Loading