Пример #1
0
 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
Пример #2
0
 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)
Пример #3
0
    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)
Пример #4
0
 def test_name(self):
     site = AdminSite()
     adm = admin.FaultAdmin(Fault, site)
     il = Fault(pk=1)
     assert adm.name(il) == str(il)
Пример #5
0
 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)]