def testDisplay(self): """We know when a value (or --) should be shown in the metadata column.""" # Not the right type and has no values. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, [], [], ['defect']) self.assertFalse(designdoc_fvv.display) # Has a value. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, ['fake value item'], [], ['defect']) self.assertTrue(designdoc_fvv.display) # Has a derived value. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, [], ['fake value item'], ['defect']) self.assertTrue(designdoc_fvv.display) # Applicable to this type of issue, it will show "--". designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, [], [], ['enhancement']) self.assertTrue(designdoc_fvv.display) # Applicable to all issues, it will show "--". estdays_fvv = tracker_views.FieldValueView(self.estdays_fd, self.config, [], [], ['enhancement']) self.assertTrue(estdays_fvv.display)
def testPhaseField(self): mtarget_fvv = tracker_views.FieldValueView(self.mtarget_fd, self.config, [], [], [], phase_name='Stage') self.assertEqual('Stage', mtarget_fvv.phase_name) self.assertEqual(ezt.boolean(True), mtarget_fvv.field_def.is_phase_field)
def testMakeBounceFieldValueViews(self): config = tracker_pb2.ProjectIssueConfig() fd = tracker_pb2.FieldDef(field_id=3, field_type=tracker_pb2.FieldTypes.INT_TYPE, applicable_type='', field_name='EstDays') phase_fd = tracker_pb2.FieldDef( field_id=4, field_type=tracker_pb2.FieldTypes.INT_TYPE, applicable_type='', field_name='Gump') config.field_defs = [ fd, phase_fd, tracker_pb2.FieldDef(field_id=5, field_type=tracker_pb2.FieldTypes.STR_TYPE) ] parsed_fvs = {3: [455]} parsed_phase_fvs = { 4: { 'stable': [73, 74], 'beta': [8], 'beta-exp': [75] }, } fvs = tracker_views.MakeBounceFieldValueViews(parsed_fvs, parsed_phase_fvs, config) self.assertEqual(len(fvs), 4) estdays_ezt_fv = template_helpers.EZTItem(val=455, docstring='', idx=0) expected = tracker_views.FieldValueView(fd, config, [estdays_ezt_fv], [], []) self.assertEqual(fvs[0].field_name, expected.field_name) self.assertEqual(fvs[0].values[0].val, expected.values[0].val) self.assertEqual(fvs[0].values[0].idx, expected.values[0].idx) self.assertTrue(fvs[0].applicable) self.assertEqual(fvs[1].field_name, phase_fd.field_name) self.assertEqual(fvs[2].field_name, phase_fd.field_name) self.assertEqual(fvs[3].field_name, phase_fd.field_name) fd.approval_id = 23 config.field_defs = [ fd, tracker_pb2.FieldDef( field_id=23, field_name='Legal', field_type=tracker_pb2.FieldTypes.APPROVAL_TYPE) ] fvs = tracker_views.MakeBounceFieldValueViews(parsed_fvs, {}, config) self.assertTrue(fvs[0].applicable)
def testSomeValues(self): """We can create a FieldValueView with some values.""" values = [template_helpers.EZTItem(val=12, docstring=None, idx=0)] derived_values = [ template_helpers.EZTItem(val=88, docstring=None, idx=0) ] estdays_fvv = tracker_views.FieldValueView(self.estdays_fd, self.config, values, derived_values, ['defect']) self.assertEqual(values, estdays_fvv.values) self.assertEqual(derived_values, estdays_fvv.derived_values) self.assertEqual('', estdays_fvv.phase_name) self.assertEqual(ezt.boolean(False), estdays_fvv.field_def.is_phase_field)
def testNoValues(self): """We can create a FieldValueView with no values.""" values = [] derived_values = [] estdays_fvv = tracker_views.FieldValueView(self.estdays_fd, self.config, values, derived_values, ['defect'], phase_name='Gate') self.assertEqual('EstDays', estdays_fvv.field_def.field_name) self.assertEqual(3, estdays_fvv.field_def.min_value) self.assertEqual(99, estdays_fvv.field_def.max_value) self.assertEqual([], estdays_fvv.values) self.assertEqual([], estdays_fvv.derived_values)
def testApplicability(self): """We know whether a field should show an editing widget.""" # Not the right type and has no values. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, [], [], ['defect']) self.assertFalse(designdoc_fvv.applicable) self.assertEqual('', designdoc_fvv.phase_name) self.assertEqual(ezt.boolean(False), designdoc_fvv.field_def.is_phase_field) # Has a value. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, ['fake value item'], [], ['defect']) self.assertTrue(designdoc_fvv.applicable) # Derived values don't cause editing fields to display. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, [], ['fake value item'], ['defect']) self.assertFalse(designdoc_fvv.applicable) # Applicable to this type of issue. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, [], [], ['enhancement']) self.assertTrue(designdoc_fvv.applicable) # Applicable to some issues in a bulk edit. designdoc_fvv = tracker_views.FieldValueView( self.designdoc_fd, self.config, [], [], ['defect', 'task', 'enhancement']) self.assertTrue(designdoc_fvv.applicable) # Applicable to all issues. estdays_fvv = tracker_views.FieldValueView(self.estdays_fd, self.config, [], [], ['enhancement']) self.assertTrue(estdays_fvv.applicable) # Explicitly set to be applicable when showing bounce values. designdoc_fvv = tracker_views.FieldValueView(self.designdoc_fd, self.config, [], [], ['defect'], applicable=True) self.assertTrue(designdoc_fvv.applicable)