Commit 6c33559f authored by Maël Kervella's avatar Maël Kervella

Add tests for details of instances of every models

parent 3f4dd43f
...@@ -276,6 +276,11 @@ class ServiceLinkSerializer(NamespacedHMSerializer): ...@@ -276,6 +276,11 @@ class ServiceLinkSerializer(NamespacedHMSerializer):
class OuverturePortListSerializer(NamespacedHMSerializer): class OuverturePortListSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.OuverturePortList` objects. """Serialize `machines.models.OuverturePortList` objects.
""" """
tcp_ports_in = NamespacedHRField(view_name='ouvertureport-detail', many=True, read_only=True)
udp_ports_in = NamespacedHRField(view_name='ouvertureport-detail', many=True, read_only=True)
tcp_ports_out = NamespacedHRField(view_name='ouvertureport-detail', many=True, read_only=True)
udp_ports_out = NamespacedHRField(view_name='ouvertureport-detail', many=True, read_only=True)
class Meta: class Meta:
model = machines.OuverturePortList model = machines.OuverturePortList
fields = ('name', 'tcp_ports_in', 'udp_ports_in', 'tcp_ports_out', fields = ('name', 'tcp_ports_in', 'udp_ports_in', 'tcp_ports_out',
...@@ -335,12 +340,15 @@ class GeneralOptionSerializer(NamespacedHMSerializer): ...@@ -335,12 +340,15 @@ class GeneralOptionSerializer(NamespacedHMSerializer):
'GTU') 'GTU')
class ServiceSerializer(NamespacedHMSerializer): class HomeServiceSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.Service` objects. """Serialize `preferences.models.Service` objects.
""" """
class Meta: class Meta:
model = preferences.Service model = preferences.Service
fields = ('name', 'url', 'description', 'image', 'api_url') fields = ('name', 'url', 'description', 'image', 'api_url')
extra_kwargs = {
'api_url': {'view_name': 'homeservice-detail'}
}
class AssoOptionSerializer(NamespacedHMSerializer): class AssoOptionSerializer(NamespacedHMSerializer):
...@@ -625,14 +633,6 @@ class OriginV4RecordSerializer(IpListSerializer): ...@@ -625,14 +633,6 @@ class OriginV4RecordSerializer(IpListSerializer):
fields = ('ipv4',) fields = ('ipv4',)
class OriginV6RecordSerializer(Ipv6ListSerializer):
"""Serialize `machines.models.Ipv6List` objects with the data needed to
generate an IPv6 Origin DNS record.
"""
class Meta(Ipv6ListSerializer.Meta):
fields = ('ipv6',)
class NSRecordSerializer(NsSerializer): class NSRecordSerializer(NsSerializer):
"""Serialize `machines.models.Ns` objects with the data needed to """Serialize `machines.models.Ns` objects with the data needed to
generate a NS DNS record. generate a NS DNS record.
...@@ -713,7 +713,7 @@ class DNSZonesSerializer(serializers.ModelSerializer): ...@@ -713,7 +713,7 @@ class DNSZonesSerializer(serializers.ModelSerializer):
soa = SOARecordSerializer() soa = SOARecordSerializer()
ns_records = NSRecordSerializer(many=True, source='ns_set') ns_records = NSRecordSerializer(many=True, source='ns_set')
originv4 = OriginV4RecordSerializer(source='origin') originv4 = OriginV4RecordSerializer(source='origin')
originv6 = OriginV6RecordSerializer(source='origin_v6') originv6 = serializers.CharField(source='origin_v6')
mx_records = MXRecordSerializer(many=True, source='mx_set') mx_records = MXRecordSerializer(many=True, source='mx_set')
txt_records = TXTRecordSerializer(many=True, source='txt_set') txt_records = TXTRecordSerializer(many=True, source='txt_set')
srv_records = SRVRecordSerializer(many=True, source='srv_set') srv_records = SRVRecordSerializer(many=True, source='srv_set')
......
This diff is collapsed.
...@@ -65,7 +65,7 @@ router.register_view(r'preferences/optionaluser', views.OptionalUserView), ...@@ -65,7 +65,7 @@ router.register_view(r'preferences/optionaluser', views.OptionalUserView),
router.register_view(r'preferences/optionalmachine', views.OptionalMachineView), router.register_view(r'preferences/optionalmachine', views.OptionalMachineView),
router.register_view(r'preferences/optionaltopologie', views.OptionalTopologieView), router.register_view(r'preferences/optionaltopologie', views.OptionalTopologieView),
router.register_view(r'preferences/generaloption', views.GeneralOptionView), router.register_view(r'preferences/generaloption', views.GeneralOptionView),
router.register_viewset(r'preferences/service', views.ServiceViewSet), router.register_viewset(r'preferences/service', views.HomeServiceViewSet, base_name='homeservice'),
router.register_view(r'preferences/assooption', views.AssoOptionView), router.register_view(r'preferences/assooption', views.AssoOptionView),
router.register_view(r'preferences/homeoption', views.HomeOptionView), router.register_view(r'preferences/homeoption', views.HomeOptionView),
router.register_view(r'preferences/mailmessageoption', views.MailMessageOptionView), router.register_view(r'preferences/mailmessageoption', views.MailMessageOptionView),
......
...@@ -275,11 +275,11 @@ class GeneralOptionView(generics.RetrieveAPIView): ...@@ -275,11 +275,11 @@ class GeneralOptionView(generics.RetrieveAPIView):
return preferences.GeneralOption.objects.first() return preferences.GeneralOption.objects.first()
class ServiceViewSet(viewsets.ReadOnlyModelViewSet): class HomeServiceViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes list and details of `preferences.models.Service` objects. """Exposes list and details of `preferences.models.Service` objects.
""" """
queryset = preferences.Service.objects.all() queryset = preferences.Service.objects.all()
serializer_class = serializers.ServiceSerializer serializer_class = serializers.HomeServiceSerializer
class AssoOptionView(generics.RetrieveAPIView): class AssoOptionView(generics.RetrieveAPIView):
......
...@@ -155,10 +155,12 @@ class DiscoverLdapRunner(DiscoverRunner): ...@@ -155,10 +155,12 @@ class DiscoverLdapRunner(DiscoverRunner):
def setup_databases(self, *args, **kwargs): def setup_databases(self, *args, **kwargs):
ret = super(DiscoverLdapRunner, self).setup_databases(*args, **kwargs) ret = super(DiscoverLdapRunner, self).setup_databases(*args, **kwargs)
print("Creating test LDAP with volatildap...")
self.ldap_server.start() self.ldap_server.start()
return ret return ret
def teardown_databases(self, *args, **kwargs): def teardown_databases(self, *args, **kwargs):
self.ldap_server.stop() self.ldap_server.stop()
print("Destroying test LDAP...")
super(DiscoverLdapRunner, self).teardown_databases(*args, **kwargs) super(DiscoverLdapRunner, self).teardown_databases(*args, **kwargs)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment