def test_select_factors_get(self): resp = self.client.get(reverse('tracks-select_factors')) self.assertEqual(resp.status_code, STATUS_OK) self._check_nav_context(resp) self.assertEqual(resp.context['step_items'], Steps.make_items(Steps.TRANSCRIPTION_FACTORS)) self.assertIsInstance(resp.context['form'], TranscriptionFactorForm) self.assertEqual(resp.context['form'].errors, {})
def test_make_items_cell_type(self): items = Steps.make_items(Steps.CELL_TYPES) self.assertEqual(items, [{ 'label': Steps.TRANSCRIPTION_FACTORS, 'is_active': False }, { 'label': Steps.CELL_TYPES, 'is_active': True }])
def test_select_factors_post_without_data(self): resp = self.client.post(reverse('tracks-select_factors')) self.assertEqual(resp.status_code, STATUS_OK) self._check_nav_context(resp) self.assertEqual(resp.context['step_items'], Steps.make_items(Steps.TRANSCRIPTION_FACTORS)) self.assertIsInstance(resp.context['form'], TranscriptionFactorForm) self.assertEqual(resp.context['form'].errors, {FormFields.TF_NAME: ['This field is required.']})
def test_select_cell_type_post_without_data(self): resp = self.client.post(reverse('tracks-select_cell_type')) self.assertEqual(resp.status_code, STATUS_OK) self._check_nav_context(resp) self.assertEqual(resp.context['step_items'], Steps.make_items(Steps.CELL_TYPES)) resp_form = resp.context['form'] self.assertIsInstance(resp_form, CellTypeForm) self.assertEqual(resp_form.errors, {FormFields.CELL_TYPE: ['This field is required.']})
def test_select_tracks_get_with_data(self): resp = self.client.get( reverse('tracks-select_tracks') + '?tf=AR&tf=ATF&celltype=8988T&celltype=CLL') self.assertEqual(resp.status_code, STATUS_OK) self._check_nav_context(resp) self.assertEqual(resp.context['step_items'], Steps.make_items(Steps.TRACKS)) tf_names = [tf.name for tf in resp.context['tfs']] self.assertEqual(tf_names, ['AR', 'ATF']) celltype_names = [ celltype.name for celltype in resp.context['celltypes'] ] self.assertEqual(celltype_names, ['8988T', 'CLL'])
def test_select_cell_type_get_with_data(self): resp = self.client.get( reverse('tracks-select_cell_type') + '?tf=AR&tf=ATF') self.assertEqual(resp.status_code, STATUS_OK) self._check_nav_context(resp) self.assertEqual(resp.context['step_items'], Steps.make_items(Steps.CELL_TYPES)) resp_form = resp.context['form'] self.assertIsInstance(resp_form, CellTypeForm) self.assertEqual(resp_form.errors, {}) tf_names = [ tf.name for tf in resp_form.cleaned_data[FormFields.TF_NAME] ] self.assertEqual(tf_names, ['AR', 'ATF'])
def test_make_items_tfs(self): items = Steps.make_items(Steps.TRANSCRIPTION_FACTORS) self.assertEqual(items, [{ 'label': Steps.TRANSCRIPTION_FACTORS, 'is_active': True }])