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):
class OuverturePortListSerializer(NamespacedHMSerializer):
"""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:
model = machines.OuverturePortList
fields = ('name', 'tcp_ports_in', 'udp_ports_in', 'tcp_ports_out',
......@@ -335,12 +340,15 @@ class GeneralOptionSerializer(NamespacedHMSerializer):
'GTU')
class ServiceSerializer(NamespacedHMSerializer):
class HomeServiceSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.Service` objects.
"""
class Meta:
model = preferences.Service
fields = ('name', 'url', 'description', 'image', 'api_url')
extra_kwargs = {
'api_url': {'view_name': 'homeservice-detail'}
}
class AssoOptionSerializer(NamespacedHMSerializer):
......@@ -625,14 +633,6 @@ class OriginV4RecordSerializer(IpListSerializer):
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):
"""Serialize `machines.models.Ns` objects with the data needed to
generate a NS DNS record.
......@@ -713,7 +713,7 @@ class DNSZonesSerializer(serializers.ModelSerializer):
soa = SOARecordSerializer()
ns_records = NSRecordSerializer(many=True, source='ns_set')
originv4 = OriginV4RecordSerializer(source='origin')
originv6 = OriginV6RecordSerializer(source='origin_v6')
originv6 = serializers.CharField(source='origin_v6')
mx_records = MXRecordSerializer(many=True, source='mx_set')
txt_records = TXTRecordSerializer(many=True, source='txt_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),
router.register_view(r'preferences/optionalmachine', views.OptionalMachineView),
router.register_view(r'preferences/optionaltopologie', views.OptionalTopologieView),
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/homeoption', views.HomeOptionView),
router.register_view(r'preferences/mailmessageoption', views.MailMessageOptionView),
......
......@@ -275,11 +275,11 @@ class GeneralOptionView(generics.RetrieveAPIView):
return preferences.GeneralOption.objects.first()
class ServiceViewSet(viewsets.ReadOnlyModelViewSet):
class HomeServiceViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes list and details of `preferences.models.Service` objects.
"""
queryset = preferences.Service.objects.all()
serializer_class = serializers.ServiceSerializer
serializer_class = serializers.HomeServiceSerializer
class AssoOptionView(generics.RetrieveAPIView):
......
......@@ -155,10 +155,12 @@ class DiscoverLdapRunner(DiscoverRunner):
def setup_databases(self, *args, **kwargs):
ret = super(DiscoverLdapRunner, self).setup_databases(*args, **kwargs)
print("Creating test LDAP with volatildap...")
self.ldap_server.start()
return ret
def teardown_databases(self, *args, **kwargs):
self.ldap_server.stop()
print("Destroying test LDAP...")
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