def test_get_qs(self): site = AdminSite() adm = admin.FaultAdmin(Fault, site) ft1 = utils.create_fault_type() ft2 = utils.create_fault_type() utils.create_fault(fault_type=[ft1, ft2]) assert adm.get_queryset(None).count() == 1
def test_get_fault_types(self): ft1 = utils.create_fault_type() ft2 = utils.create_fault_type() fault = utils.create_fault(fault_type=[ft1, ft2]) site = AdminSite() adm = admin.FaultAdmin(Fault, site) qs = fault.fault_types.order_by("code").values_list("code", flat=True) assert adm.get_fault_types(fault) == ', '.join(qs)
def setUp(self): self.user = qa_utils.create_user() self.unit = qa_utils.create_unit() self.fault_type = FaultType.objects.create(code="ABC", slug="abc") u_models.Modality.objects.all().delete() self.modality = qa_utils.create_modality(name="modality") self.adm = admin.FaultAdmin(Fault, AdminSite()) self.mf = admin.ModalityFilter(mock.Mock(), {}, Fault, self.adm)
def test_name(self): site = AdminSite() adm = admin.FaultAdmin(Fault, site) il = Fault(pk=1) assert adm.name(il) == str(il)
def test_modality_filter_lookups(self): site = AdminSite() adm = admin.FaultAdmin(Fault, site) modality = u_models.Modality.objects.create(name="modality") lookups = admin.ModalityFilter(None, {}, Fault, adm).lookups(None, adm) assert list(lookups) == [(modality.pk, modality.name)]