Update instrument type query test and fix multiple similar types bug

This commit is contained in:
Ramon Wenger 2021-11-11 14:00:07 +01:00
parent 7a850b3a94
commit eedf7202d6
2 changed files with 5 additions and 1 deletions

View File

@ -64,4 +64,4 @@ class InstrumentQuery(object):
return BasicKnowledge.objects.all().live() return BasicKnowledge.objects.all().live()
def resolve_instrument_types(self, info, **kwargs): def resolve_instrument_types(self, info, **kwargs):
return InstrumentType.objects.filter(instruments__isnull=False) return InstrumentType.objects.filter(instruments__isnull=False).distinct()

View File

@ -20,6 +20,10 @@ class InstrumentTypesQueryTestCase(SkillboxTestCase):
InstrumentTypeFactory(name='Guitar') InstrumentTypeFactory(name='Guitar')
self.instrument = InstrumentFactory(new_type=self.type) self.instrument = InstrumentFactory(new_type=self.type)
InstrumentFactory(new_type=second_type) InstrumentFactory(new_type=second_type)
InstrumentFactory(new_type=second_type)
InstrumentFactory(new_type=second_type)
InstrumentFactory(new_type=second_type)
InstrumentFactory(new_type=second_type)
def test_instrument_types_empty_not_returned(self): def test_instrument_types_empty_not_returned(self):
result = self.get_client().get_result(INSTRUMENT_TYPES_QUERY) result = self.get_client().get_result(INSTRUMENT_TYPES_QUERY)