File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ def filter_queryset(self, queryset):
147
147
148
148
149
149
class HostFilterSet (filters .FilterSet ):
150
+ zone = filters .NumberFilter (field_name = "zone_id" )
151
+ zone__name = filters .CharFilter (field_name = "zone_id__name" )
152
+
150
153
class Meta :
151
154
model = Host
152
155
fields = {
@@ -186,8 +189,11 @@ class Meta:
186
189
"srvs__weight" : INT_OPERATORS ,
187
190
"srvs__port" : INT_OPERATORS ,
188
191
"srvs__ttl" : INT_OPERATORS ,
189
- "zone" : INT_OPERATORS ,
190
- "zone__name" : STRING_OPERATORS ,
192
+ # These are relationships to Zone, which for some reason are named zone_id in the host _model_,
193
+ # even though the field in the ForwardZone model is named zone and the field returned to the
194
+ # user is called zone...
195
+ "zone_id" : INT_OPERATORS ,
196
+ "zone_id__name" : STRING_OPERATORS ,
191
197
** CREATED_UPDATED ,
192
198
}
193
199
Original file line number Diff line number Diff line change @@ -233,6 +233,10 @@ def test_zones_404_not_found(self):
233
233
""""Deleting a non-existing entry should return 404"""
234
234
self .assert_delete_and_404 (self .basepath + '1.11.in-addr.arpa' )
235
235
236
+ def test_zone_by_host_200_ok_but_empty (self ):
237
+ res = self .assert_get (f'/hosts/?zone={ self .zone_one .pk } ' )
238
+ self .assertEqual (res .json ()['count' ], 0 )
239
+
236
240
237
241
class ZonesForwardDelegationTestCase (MregAPITestCase ):
238
242
""" This class defines test testsuite for api/zones/forward/<name>/delegations/
You can’t perform that action at this time.
0 commit comments