not in perms) else: assert f"{permission_type}_singlepolygonannotation" in perms def test_model_permissions(self, TwoRetinaPolygonAnnotationSets, user_type): user = get_user_from_user_type( user_type, grader=TwoRetinaPolygonAnnotationSets.grader1) perms = get_perms(user, TwoRetinaPolygonAnnotationSets.polygonset1) default_permissions = (TwoRetinaPolygonAnnotationSets.polygonset1. _meta.default_permissions) for permission_type in default_permissions: if user_type == "retina_grader_non_allowed": assert f"{permission_type}_polygonannotationset" not in perms else: assert f"{permission_type}_polygonannotationset" in perms factories = { "etdrs": ETDRSGridAnnotationFactory, "measurement": MeasurementAnnotationFactory, "boolean": BooleanClassificationAnnotationFactory, "integer": IntegerClassificationAnnotationFactory, "coordinates": CoordinateListAnnotationFactory, "polygonset": PolygonAnnotationSetFactory, "singlepolygon": SinglePolygonAnnotationFactory, "landmarkset": LandmarkAnnotationSetFactory, "singlelandmark": SingleLandmarkAnnotationFactory, } batch_test_factories(factories, TestAnnotationModels)
ImageFileFactoryWithMHDFile, ImageFileFactoryWithRAWFile, ) from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestRetinaImagesModels: # test functions are added dynamically to this class def test_retina_image_str(self): model = ImageFactory() assert str(model) == f"Image {model.name} {model.shape_without_color}" factories = {"image": ImageFactory} batch_test_factories(factories, TestRetinaImagesModels) @pytest.mark.django_db class TestGetSitkImage: def test_multiple_mhds(self): extra_mhd = ImageFileFactoryWithMHDFile() extra_mhd_file = ImageFileFactoryWithMHDFile() extra_raw = ImageFileFactoryWithRAWFile() extra_raw_file = ImageFileFactoryWithRAWFile() image = ImageFactoryWithImageFile( files=(extra_mhd, extra_raw, extra_mhd_file, extra_raw_file) ) try: image.get_sitk_image() pytest.fail("No MultipleObjectsReturned exception")
def test_model_permissions( self, TwoRetinaPolygonAnnotationSets, user_type ): user = get_user_from_user_type( user_type, grader=TwoRetinaPolygonAnnotationSets.grader1 ) perms = get_perms(user, TwoRetinaPolygonAnnotationSets.polygonset1) default_permissions = ( TwoRetinaPolygonAnnotationSets.polygonset1._meta.default_permissions ) for permission_type in default_permissions: if user_type == "retina_grader_non_allowed": assert f"{permission_type}_polygonannotationset" not in perms else: assert f"{permission_type}_polygonannotationset" in perms factories = { "etdrs": ETDRSGridAnnotationFactory, "measurement": MeasurementAnnotationFactory, "boolean": BooleanClassificationAnnotationFactory, "integer": IntegerClassificationAnnotationFactory, "coordinates": CoordinateListAnnotationFactory, "polygonset": PolygonAnnotationSetFactory, "singlepolygon": SinglePolygonAnnotationFactory, "landmarkset": LandmarkAnnotationSetFactory, "singlelandmark": SingleLandmarkAnnotationFactory, } batch_test_factories(factories, TestAnnotationModels)
import pytest from tests.patients_tests.factories import PatientFactory from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestPatientsModels: # test functions are added dynamically to this class def test_study_str(self): model = PatientFactory() assert str(model) == "<{} {}>".format( model.__class__.__name__, model.name ) factories = {"archive": PatientFactory} batch_test_factories(factories, TestPatientsModels)
import pytest from tests.archives_tests.factories import ArchiveFactory from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestArchivesModels: # test functions are added dynamically to this class def test_study_str(self): model = ArchiveFactory() assert str(model) == "<{} {}>".format(model.__class__.__name__, model.name) factories = {"archive": ArchiveFactory} batch_test_factories(factories, TestArchivesModels)
import pytest from tests.studies_tests.factories import StudyFactory from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestStudiesModels: # test functions are added dynamically to this class def test_study_str(self): model = StudyFactory() assert str(model) == "<{} {}>".format( model.__class__.__name__, model.name ) factories = {"study": StudyFactory} batch_test_factories(factories, TestStudiesModels)
ImageFileFactoryWithMHDFile, ImageFileFactoryWithRAWFile, ) from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestRetinaImagesModels: # test functions are added dynamically to this class def test_retina_image_str(self): model = ImageFactory() assert str(model) == f"Image {model.name} {model.shape_without_color}" factories = {"image": ImageFactory} batch_test_factories(factories, TestRetinaImagesModels) @pytest.mark.django_db class TestGetSitkImage: def test_multiple_mhds(self): extra_mhd = ImageFileFactoryWithMHDFile() extra_mhd_file = ImageFileFactoryWithMHDFile() extra_raw = ImageFileFactoryWithRAWFile() extra_raw_file = ImageFileFactoryWithRAWFile() image = ImageFactoryWithImageFile(files=(extra_mhd, extra_raw, extra_mhd_file, extra_raw_file)) try: image.get_sitk_image() pytest.fail("No MultipleObjectsReturned exception")
import pytest from tests.studies_tests.factories import StudyFactory from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestStudiesModels: # test functions are added dynamically to this class def test_study_str(self): model = StudyFactory() assert str(model) == "<{} {}>".format(model.__class__.__name__, model.name) factories = {"study": StudyFactory} batch_test_factories(factories, TestStudiesModels)
import pytest from tests.registrations_tests.factories import OctObsRegistrationFactory from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestRegistrationModels: # test functions are added dynamically to this class pass factories = {"octobsregistration": OctObsRegistrationFactory} batch_test_factories(factories, TestRegistrationModels)
import pytest from tests.archives_tests.factories import ArchiveFactory from tests.model_helpers import batch_test_factories @pytest.mark.django_db class TestArchivesModels: # test functions are added dynamically to this class def test_study_str(self): model = ArchiveFactory() assert str(model) == "<{} {}>".format( model.__class__.__name__, model.name ) factories = {"archive": ArchiveFactory} batch_test_factories(factories, TestArchivesModels)