def test_main_no_outdir(self, mock_docopt, mock_file):
     mock_file.return_value = True
     mock_docopt.return_value = {'--file': 'file', '--outdir': 'outdir'}
     try:
         main()
     except Exception as e:
         assert 'Output directory outdir not found' in str(e)
 def test_main_replacement(self, mock_isfile, mock_isdir, mock_docopt,
                           mock_apply_regex):
     mock_isdir.return_value = True
     mock_isfile.return_value = True
     mock_docopt.return_value = {
         '--replacement': 'replacement',
         '--file': 'file',
         '--outdir': 'outdir',
         '--regex': 'regex',
         '--package': None
     }
     main()
     mock_apply_regex.assert_called_once_with('file', 'outdir/file',
                                              'regex', 'replacement')
Exemplo n.º 3
0
 def test_main_package(self, mock_isfile, mock_isdir, mock_docopt,
                       mock_find_pkg, mock_apply_regex):
     mock_isdir.return_value = True
     mock_isfile.return_value = True
     mock_docopt.return_value = {
         '--package': 'package',
         '--file': 'file',
         '--outdir': 'outdir',
         '--regex': 'regex'
     }
     mock_find_pkg.return_value = '0.0.1'
     main()
     mock_find_pkg.assert_called_once_with('package', './repos')
     mock_apply_regex.assert_called_once_with('file', 'outdir/file',
                                              'regex', '0.0.1')
 def test_main_package_parse_version_invalid_argument(
         self, mock_isfile, mock_isdir, mock_docopt, mock_find_pkg):
     mock_find_pkg.return_value = '1.34.2'
     mock_isdir.return_value = True
     mock_isfile.return_value = True
     mock_docopt.return_value = {
         '--package': 'package',
         '--file': 'file',
         '--outdir': 'outdir',
         '--regex': 'regex',
         '--parse-version': 'invalid-value'
     }
     exception = False
     try:
         main()
     except Exception as e:
         assert 'Invalid value for this flag.' in str(e)
         exception = True
     assert exception
 def test_main_package_parse_version(self, mock_isfile, mock_isdir,
                                     mock_docopt, mock_find_pkg,
                                     mock_apply_regex, mock_match_version):
     mock_isdir.return_value = True
     mock_isfile.return_value = True
     mock_docopt.return_value = {
         '--package': 'package',
         '--file': 'file',
         '--outdir': 'outdir',
         '--regex': 'regex',
         '--parse-version': 'minor'
     }
     mock_find_pkg.return_value = '0.0.1'
     mock_match_version.return_value = '0.0'
     main()
     mock_find_pkg.assert_called_once_with('package', './repos')
     mock_apply_regex.assert_called_once_with('file', 'outdir/file',
                                              'regex', '0.0')
     mock_match_version.assert_called_once_with('^(\d+(\.\d+){0,1})',
                                                '0.0.1')
 def test_main_no_file(self, mock_docopt):
     mock_docopt.return_value = {'--file': 'file'}
     try:
         main()
     except Exception as e:
         assert 'File file not found' in str(e)