|
|
|
@ -227,8 +227,6 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
# For more details, see |
|
|
|
# https://docs.djangoproject.com/en/1.10/topics/testing/tools/#testcase |
|
|
|
|
|
|
|
super(APIEndpointsTestCase, cls).setUpClass() |
|
|
|
|
|
|
|
# A user with no rights |
|
|
|
cls.stduser = users.User.objects.create_user( |
|
|
|
"apistduser", "apistduser", "apistduser@example.net", "apistduser" |
|
|
|
@ -261,22 +259,22 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
registered=datetime.datetime.now(datetime.timezone.utc), |
|
|
|
telephone="0123456789", |
|
|
|
uid_number=21102, |
|
|
|
rezo_rez_uid=21102, |
|
|
|
) |
|
|
|
cls.users_user_1 = cls.users_adherent_1 |
|
|
|
cls.cotisations_article_1 = cotisations.Article.objects.create( |
|
|
|
name="cotisations_article_1", |
|
|
|
prix=10, |
|
|
|
duration=1, |
|
|
|
duration_days_membership=0, |
|
|
|
duration_membership=1, |
|
|
|
duration_days_connection=0, |
|
|
|
duration_connection=1, |
|
|
|
type_user=cotisations.Article.USER_TYPES[0][0], |
|
|
|
type_cotisation=cotisations.Article.COTISATION_TYPE[0][0], |
|
|
|
) |
|
|
|
cls.cotisations_banque_1 = cotisations.Banque.objects.create( |
|
|
|
name="cotisations_banque_1" |
|
|
|
) |
|
|
|
cls.cotisations_paiement_1 = cotisations.Paiement.objects.create( |
|
|
|
moyen="cotisations_paiement_1", |
|
|
|
type_paiement=cotisations.Paiement.PAYMENT_TYPES[0][0], |
|
|
|
) |
|
|
|
cls.cotisations_facture_1 = cotisations.Facture.objects.create( |
|
|
|
user=cls.users_user_1, # Dep users.User |
|
|
|
@ -292,8 +290,10 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
number=2, |
|
|
|
name="cotisations_vente_1", |
|
|
|
prix=10, |
|
|
|
duration=1, |
|
|
|
type_cotisation=cotisations.Vente.COTISATION_TYPE[0][0], |
|
|
|
duration_days_membership=0, |
|
|
|
duration_membership=1, |
|
|
|
duration_days_connection=0, |
|
|
|
duration_connection=1, |
|
|
|
) |
|
|
|
# A cotisation is automatically created by the Vente object and |
|
|
|
# trying to create another cotisation associated with this vente |
|
|
|
@ -328,7 +328,7 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
vlan_id=0, name="machines_vlan_1", comment="machines Vlan 1" |
|
|
|
) |
|
|
|
cls.machines_iptype_1 = machines.IpType.objects.create( |
|
|
|
type="machines_iptype_1", |
|
|
|
name="machines_iptype_1", |
|
|
|
extension=cls.machines_extension_1, # Dep machines.Extension |
|
|
|
need_infra=False, |
|
|
|
domaine_ip_start="10.0.0.1", |
|
|
|
@ -343,14 +343,14 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
ipv4="10.0.0.1", ip_type=cls.machines_iptype_1 # Dep machines.IpType |
|
|
|
) |
|
|
|
cls.machines_machinetype_1 = machines.MachineType.objects.create( |
|
|
|
type="machines_machinetype_1", |
|
|
|
name="machines_machinetype_1", |
|
|
|
ip_type=cls.machines_iptype_1, # Dep machines.IpType |
|
|
|
) |
|
|
|
cls.machines_interface_1 = machines.Interface.objects.create( |
|
|
|
ipv4=cls.machines_iplist_1, # Dep machines.IpList |
|
|
|
mac_address="00:00:00:00:00:00", |
|
|
|
machine=cls.machines_machine_1, # Dep machines.Machine |
|
|
|
type=cls.machines_machinetype_1, # Dep machines.MachineType |
|
|
|
machine_type=cls.machines_machinetype_1, # Dep machines.MachineType |
|
|
|
details="machines Interface 1", |
|
|
|
# port_lists=[cls.machines_ouvertureportlist_1] # Dep machines.OuverturePortList |
|
|
|
) |
|
|
|
@ -438,8 +438,12 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
name="machines_machine_1", |
|
|
|
active=True, |
|
|
|
) |
|
|
|
cls.topologie_dormitory_1 = topologie.Dormitory.objects.create( |
|
|
|
name="topologie_dormitory_1" |
|
|
|
) |
|
|
|
cls.topologie_building_1 = topologie.Building.objects.create( |
|
|
|
name="topologie_building_1" |
|
|
|
name="topologie_building_1", |
|
|
|
dormitory=cls.topologie_dormitory_1, # Dep topologie.Dormitory |
|
|
|
) |
|
|
|
cls.topologie_switchbay_1 = topologie.SwitchBay.objects.create( |
|
|
|
name="topologie_switchbay_1", |
|
|
|
@ -464,29 +468,35 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
switchbay=cls.topologie_switchbay_1, # Dep topologie.SwitchBay |
|
|
|
) |
|
|
|
cls.topologie_room_1 = topologie.Room.objects.create( |
|
|
|
name="topologie_romm_1", details="topologie Room 1" |
|
|
|
name="topologie_romm_1", details="topologie Room 1", |
|
|
|
building=cls.topologie_building_1, # Dep topologie.Building |
|
|
|
) |
|
|
|
cls.topologie_port_profile_1 = topologie.PortProfile.objects.create( |
|
|
|
name="topologie_port_profile_1", |
|
|
|
profil_default=topologie.PortProfile.PROFIL_DEFAULT[0][0], |
|
|
|
on_dormitory=cls.topologie_dormitory_1, |
|
|
|
radius_type="inactive", |
|
|
|
radius_mode="COMMON", |
|
|
|
) |
|
|
|
cls.topologie_port_1 = topologie.Port.objects.create( |
|
|
|
switch=cls.topologie_switch_1, # Dep topologie.Switch |
|
|
|
port=1, |
|
|
|
room=cls.topologie_room_1, # Dep topologie.Room |
|
|
|
radius=topologie.Port.STATES[0][0], |
|
|
|
vlan_force=cls.machines_vlan_1, # Dep machines.Vlan |
|
|
|
custom_profile=cls.topologie_port_profile_1, |
|
|
|
details="topologie_switch_1", |
|
|
|
) |
|
|
|
cls.topologie_port_2 = topologie.Port.objects.create( |
|
|
|
switch=cls.topologie_switch_1, # Dep topologie.Switch |
|
|
|
port=2, |
|
|
|
machine_interface=cls.machines_interface_1, # Dep machines.Interface |
|
|
|
radius=topologie.Port.STATES[0][0], |
|
|
|
vlan_force=cls.machines_vlan_1, # Dep machines.Vlan |
|
|
|
custom_profile=cls.topologie_port_profile_1, |
|
|
|
details="topologie_switch_1", |
|
|
|
) |
|
|
|
cls.topologie_port_3 = topologie.Port.objects.create( |
|
|
|
switch=cls.topologie_switch_1, # Dep topologie.Switch |
|
|
|
port=3, |
|
|
|
room=cls.topologie_room_1, # Dep topologie.Room |
|
|
|
radius=topologie.Port.STATES[0][0], |
|
|
|
custom_profile=cls.topologie_port_profile_1, |
|
|
|
# Do not defines related because circular dependency # Dep machines.Vlan |
|
|
|
details="topologie_switch_1", |
|
|
|
) |
|
|
|
@ -512,7 +522,6 @@ class APIEndpointsTestCase(APITestCase): |
|
|
|
registered=datetime.datetime.now(datetime.timezone.utc), |
|
|
|
telephone="0123456789", |
|
|
|
uid_number=21103, |
|
|
|
rezo_rez_uid=21103, |
|
|
|
) |
|
|
|
# Need merge of MR145 to work |
|
|
|
# TODO: Merge !145 |
|
|
|
@ -749,7 +758,7 @@ class APIPaginationTestCase(APITestCase): |
|
|
|
@classmethod |
|
|
|
def tearDownClass(cls): |
|
|
|
cls.superuser.delete() |
|
|
|
super(APIPaginationTestCase, self).tearDownClass() |
|
|
|
super().tearDownClass() |
|
|
|
|
|
|
|
def test_pagination(self): |
|
|
|
"""Tests that every endpoint is using the pagination correctly. |
|
|
|
|