Esempio n. 1
0
    def test_replace_date_in_release_date(self, mock_config_list, mock_arg):
        self.tearDown()
        mock_config_list.return_value = [self._path]
        Configuration.NAMESPACE = 'tests.mocks'

        config = Configuration(filename='valid_config.json')
        config.check = True
        self.assertTrue(config.check)
        self.assertIsInstance(config.replacements, Replacements)

        today = date.today()
        releasedate = Calendar().get_last_day_of_month_ahead()

        value_format = '%A, %d %B %Y'
        reldate = datetime.strftime(
            releasedate, value_format.replace('%d', '{th}')).replace(
                '{th}', (str(releasedate.day) +
                         ("th" if 4 <= releasedate.day % 100 <= 20 else {
                             1: "st",
                             2: "nd",
                             3: "rd"
                         }.get(releasedate.day % 10, "th"))))

        self.assertEquals(config.replacements.replace('{RELEASE_DATE}'),
                          reldate)
Esempio n. 2
0
 def test_report_callback_returns_callback(self, mock_config_list,
                                           mock_parser):
     mock_parser.return_value = []
     mock_config_list.return_value = [self._path]
     Configuration.NAMESPACE = 'pyccata.core'
     config = Configuration(filename='valid_config.json')
     config.check = True
     report = ReportManager()
     report.add_callback('test', 'test_callback')
     self.assertEquals('test_callback', report.get_callback('test'))
Esempio n. 3
0
 def test_config_parse_flags(self, mock_config_list, mock_arguments,
                             mock_parser):
     mock_config_list.return_value = [self._path]
     Configuration.NAMESPACE = 'tests.mocks'
     mock_parser.return_value = []
     config = Configuration(filename='valid_config.json')
     self.assertGreater(mock_parser.call_count, 0)
     config.check = True
     self.assertTrue(config.check)
     self.assertIsInstance(config.replacements, Replacements)
Esempio n. 4
0
    def test_replace_words_in_string(self, string, response, mock_config_list,
                                     mock_arg):
        self.tearDown()
        mock_config_list.return_value = [self._path]
        Configuration.NAMESPACE = 'tests.mocks'

        config = Configuration(filename='valid_config.json')
        config.check = True
        self.assertTrue(config.check)
        self.assertIsInstance(config.replacements, Replacements)
        self.assertEquals(config.replacements.replace(string), response)
Esempio n. 5
0
    def test_build_pipeline(self, mock_locations, mock_flags):
        mock_locations.return_value = [self._path]
        config = Configuration(filename='pipeline-config.json')
        config.check = True
        self._cleanup()

        pipeline = PipelineController()
        with patch('subprocess.Popen.poll') as mock_poll:
            with patch('subprocess.Popen._execute_child') as mock_command:
                with patch('subprocess.Popen.communicate') as mock_comms:
                    mock_comms.return_value = True
                    pipeline.build()
                    self.assertEquals(3, pipeline.length)
Esempio n. 6
0
    def setUp(self, mock_config, mock_parser, mock_log):
        self.tearDown()
        mock_log.return_value = None
        Logger._instance = mock_log
        path = os.path.dirname(os.path.realpath(__file__ + '../../../../'))
        self._path = os.path.join(path, os.path.join('tests', 'conf'))
        mock_config.return_value = [self._path]
        mock_parser.return_value = []
        config = None

        with patch('argparse.ArgumentParser.add_argument'):
            config = Configuration(filename='valid_config.json')
        config.check = True
        self._report_manager = ReportManager()
        self._thread_manager = ThreadManager()
Esempio n. 7
0
    def test_replace_date_in_fix_version(self, mock_config_list, mock_arg):
        self.tearDown()
        mock_config_list.return_value = [self._path]
        Configuration.NAMESPACE = 'tests.mocks'

        config = Configuration(filename='valid_config.json')
        config.check = True
        self.assertTrue(config.check)
        self.assertIsInstance(config.replacements, Replacements)
        config.replacements.find('FIX_VERSION').value = '28/Jul/2016'

        today = date.today()
        releasedate = today + timedelta((3 - today.weekday()) % 7)
        self.assertEquals(config.replacements.replace('{FIX_VERSION}'),
                          '28/Jul/2016')
        self.assertEquals(config.replacements.replace('some text'),
                          'Some Replacement Text')
Esempio n. 8
0
    def test_config_getattr_method(self, data_key, data_driver,
                                   mock_config_list, mock_load):
        mock_config = DataProviders._get_config_for_test(manager=data_driver,
                                                         reporting=data_driver)
        mock_load.return_value = None
        self.tearDown()

        mock_config_list.return_value = [self._path]
        Configuration._configuration = mock_config
        Configuration.NAMESPACE = 'tests.mocks'

        config = Configuration(filename='config_sections.json')
        config.check = True
        required_elements = [data_key]
        config.validate_config(required_elements)
        mock_load.assert_called_once_with()
        self.assertTrue(config.check)
        with self.assertRaises(AttributeError):
            config.iamnothere