def test_all_filters(self): # Create 8 pixelset make_development_fixtures(n_pixel_sets=8, n_pixels_per_set=1) # Create a special Pixel Set which will match all filters species = factories.SpeciesFactory() strain = factories.StrainFactory(species=species) omics_unit_type = factories.OmicsUnitTypeFactory() omics_unit = factories.OmicsUnitFactory( strain=strain, type=omics_unit_type, ) omics_area = factories.OmicsAreaFactory() experiment = factories.ExperimentFactory(omics_area=omics_area) experiment_tag = 'candida' experiment.tags = experiment_tag experiment.save() analysis = factories.AnalysisFactory(experiments=[ experiment, ]) pixel_set = factories.PixelSetFactory(analysis=analysis) factories.PixelFactory( omics_unit=omics_unit, pixel_set=pixel_set, ) # no filter response = self.client.get(self.url) self.assertContains(response, '<tr class="pixelset">', count=9) # all filters tag = models.Tag.objects.get(name=experiment_tag) data = { 'species': [ species.id, ], 'omics_unit_types': [ omics_unit_type.id, ], 'omics_area': [ omics_area.id, ], 'tags': [ tag.id, ], } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=1)
def setUp(self): self.user = factories.PixelerFactory( is_active=True, is_staff=True, is_superuser=True, ) self.client.login( username=self.user.username, password=factories.PIXELER_PASSWORD, ) self.pixel_set = factories.PixelSetFactory() self.pixels = factories.PixelFactory.create_batch( 2, pixel_set=self.pixel_set) self.url = self.pixel_set.get_absolute_url()
def setUp(self): self.user = factories.PixelerFactory( is_active=True, is_staff=True, is_superuser=True, ) self.client.login( username=self.user.username, password=factories.PIXELER_PASSWORD, ) self.pixel_set = factories.PixelSetFactory() self.pixel_set.analysis.experiments.add(factories.ExperimentFactory()) factories.PixelFactory.create_batch(10, pixel_set=self.pixel_set) self.url = self.pixel_set.get_export_pixels_url()
def test_pixels_limit(self): response = self.client.get(self.url) self.assertContains(response, '<tr class="pixel">', count=self.n_pixels) # Generate a new pixelset with limit+ pixels n_pixels = 101 pixel_set = factories.PixelSetFactory() factories.PixelFactory.create_batch(n_pixels, pixel_set=pixel_set) response = self.client.get(pixel_set.get_absolute_url()) self.assertContains(response, '<tr class="pixel">', count=PixelSetDetailView.pixels_limit) self.assertNotContains(response, 'Download a CSV file with the selected Pixels')
def setUp(self): self.user = factories.PixelerFactory( is_active=True, is_staff=True, is_superuser=True, ) self.client.login( username=self.user.username, password=factories.PIXELER_PASSWORD, ) self.pixel_set = factories.PixelSetFactory() self.pixels = factories.PixelFactory.create_batch( 2, pixel_set=self.pixel_set) self.url = reverse('explorer:pixelset_detail_quality_scores', kwargs={'pk': str(self.pixel_set.id)})
def setUp(self): self.user = factories.PixelerFactory( is_active=True, is_staff=True, is_superuser=True, ) self.client.login( username=self.user.username, password=factories.PIXELER_PASSWORD, ) self.pixel_set = factories.PixelSetFactory() self.pixels = factories.PixelFactory.create_batch( 2, pixel_set=self.pixel_set ) self.url = reverse('explorer:pixelset_selection_cumulative_values')
def test_tags_filter(self): # Create 8 pixelset make_development_fixtures(n_pixel_sets=8, n_pixels_per_set=1) omics_area = factories.OmicsAreaFactory() experiment = factories.ExperimentFactory(omics_area=omics_area) experiment_tag = 'candida' experiment.tags = experiment_tag experiment.save() analysis = factories.AnalysisFactory(experiments=[ experiment, ]) analysis_tag = 'msms/time' analysis.tags = analysis_tag analysis.save() factories.PixelSetFactory(analysis=analysis) # no filter response = self.client.get(self.url) self.assertContains(response, '<tr class="pixelset">', count=9) # tags filter tag = models.Tag.objects.get(name=experiment_tag) data = { 'tags': [ tag.id, ] } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=1) tag = models.Tag.objects.get(name=analysis_tag) data = { 'tags': [ tag.id, ] } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=1)
def test_omics_areas_filter(self): # Create 8 pixelset make_development_fixtures(n_pixel_sets=8, n_pixels_per_set=1) omics_area = factories.OmicsAreaFactory() experiment = factories.ExperimentFactory(omics_area=omics_area) analysis = factories.AnalysisFactory(experiments=[ experiment, ]) factories.PixelSetFactory(analysis=analysis) # no filter response = self.client.get(self.url) self.assertContains(response, '<tr class="pixelset">', count=9) # omics_areas filter data = { 'omics_areas': [ omics_area.id, ] } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=1)
def test_tags_tree_filter(self): # Create 8 pixelset make_development_fixtures(n_pixel_sets=8, n_pixels_per_set=1) # Create two pixelsets with tags omics_area = factories.OmicsAreaFactory() experiment = factories.ExperimentFactory(omics_area=omics_area) first_analysis = factories.AnalysisFactory(experiments=[ experiment, ]) first_analysis_tags = 'candida/glabrata/cbs138' first_analysis.tags = first_analysis_tags first_analysis.save() first_pixelset = factories.PixelSetFactory(analysis=first_analysis) second_analysis = factories.AnalysisFactory(experiments=[ experiment, ]) second_analysis_tags = 'candida' second_analysis.tags = second_analysis_tags second_analysis.save() second_pixelset = factories.PixelSetFactory(analysis=second_analysis) # no filter response = self.client.get(self.url) self.assertContains(response, '<tr class="pixelset">', count=10) # tags filter tag = models.Tag.objects.get(name=first_analysis_tags) data = { 'tags': [ tag.id, ] } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=1) self.assertContains( response, ('<td class="filename">' '<a' f' href="{first_pixelset.get_absolute_url()}"' ' title="More information about this Pixel Set"' '>' '<!-- Pixel Set file name -->' f'{filename(first_pixelset.pixels_file.name)}' '</a>' '</td>'), count=1, html=True, ) tag = models.Tag.objects.get(name=second_analysis_tags) data = { 'tags': [ tag.id, ] } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=2) self.assertContains( response, ('<td class="filename">' '<a' f' href="{first_pixelset.get_absolute_url()}"' ' title="More information about this Pixel Set"' '>' '<!-- Pixel Set file name -->' f'{filename(first_pixelset.pixels_file.name)}' '</a>' '</td>'), count=1, html=True, ) self.assertContains( response, ('<td class="filename">' '<a' f' href="{second_pixelset.get_absolute_url()}"' ' title="More information about this Pixel Set"' '>' '<!-- Pixel Set file name -->' f'{filename(second_pixelset.pixels_file.name)}' '</a>' '</td>'), count=1, html=True, )
def test_omics_areas_tree_filter(self): # Create 8 pixelset make_development_fixtures(n_pixel_sets=8, n_pixels_per_set=1) # Create a parent omics area and link it to a Pixel Set parent_omics_area = factories.OmicsAreaFactory() first_experiment = factories.ExperimentFactory( omics_area=parent_omics_area) first_analysis = factories.AnalysisFactory(experiments=[ first_experiment, ]) first_pixelset = factories.PixelSetFactory(analysis=first_analysis) # Create a child omics are and link it to a Pixel Set child_omics_area = factories.OmicsAreaFactory(parent=parent_omics_area) second_experiment = factories.ExperimentFactory( omics_area=child_omics_area) second_analysis = factories.AnalysisFactory(experiments=[ second_experiment, ]) second_pixelset = factories.PixelSetFactory(analysis=second_analysis) # no filter response = self.client.get(self.url) self.assertContains(response, '<tr class="pixelset">', count=10) # omics_areas filter data = { 'omics_areas': [ child_omics_area.id, ] } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=1) self.assertContains( response, ('<td class="filename">' '<a' f' href="{second_pixelset.get_absolute_url()}"' ' title="More information about this Pixel Set"' '>' '<!-- Pixel Set file name -->' f'{filename(second_pixelset.pixels_file.name)}' '</a>' '</td>'), count=1, html=True, ) data = { 'omics_areas': [ parent_omics_area.id, ] } response = self.client.get(self.url, data) self.assertContains(response, '<tr class="pixelset">', count=2) self.assertContains( response, ('<td class="filename">' '<a' f' href="{first_pixelset.get_absolute_url()}"' ' title="More information about this Pixel Set"' '>' '<!-- Pixel Set file name -->' f'{filename(first_pixelset.pixels_file.name)}' '</a>' '</td>'), count=1, html=True, ) self.assertContains( response, ('<td class="filename">' '<a' f' href="{second_pixelset.get_absolute_url()}"' ' title="More information about this Pixel Set"' '>' '<!-- Pixel Set file name -->' f'{filename(second_pixelset.pixels_file.name)}' '</a>' '</td>'), count=1, html=True, )