Exemple #1
0
    def test_tr_description_combining(self):
        """
        Verify that translated description is properly generated
        """
        job = JobDefinition(self._split_description_record.data)

        def side_effect(arg):
            return {
                'description': None,
                'PURPOSE': 'TR_PURPOSE',
                'STEPS': 'TR_STEPS',
                'VERIFICATION': 'TR_VERIFICATION',
                'purpose': 'tr_purpose_value',
                'steps': 'tr_steps_value',
                'verification': 'tr_verification_value'
            }[arg]
        with mock.patch.object(job, "get_translated_record_value") as mgtrv:
            mgtrv.side_effect = side_effect
            with mock.patch('plainbox.impl.unit.job._') as mock_gettext:
                mock_gettext.side_effect = side_effect
                retval = job.tr_description()
        mgtrv.assert_any_call('description')
        mgtrv.assert_any_call('purpose')
        mgtrv.assert_any_call('steps')
        mgtrv.assert_any_call('verification')
        self.assertEqual(mgtrv.call_count, 4)
        mock_gettext.assert_any_call('PURPOSE')
        mock_gettext.assert_any_call('STEPS')
        mock_gettext.assert_any_call('VERIFICATION')
        self.assertEqual(mock_gettext.call_count, 3)
        expected = ("TR_PURPOSE:\ntr_purpose_value\nTR_STEPS:\n"
                    "tr_steps_value\nTR_VERIFICATION:\ntr_verification_value")
        self.assertEqual(retval, expected)
Exemple #2
0
 def test_tr_description(self):
     """
     Verify that Provider1.tr_description() works as expected
     """
     job = JobDefinition(self._full_record.data)
     with mock.patch.object(job, "get_translated_record_value") as mgtrv:
         retval = job.tr_description()
     # Ensure that get_translated_record_value() was called
     mgtrv.assert_called_once_with('description')
     # Ensure tr_description() returned its return value
     self.assertEqual(retval, mgtrv())