コード例 #1
0
 def test_get_paths_fromlookback(self, mock_getpaths_fromlookback):
     src_keys = ["lookback"]
     for src in src_keys:
         self._options_dict.update({src: "20"})
     _options = Bunch(**self._options_dict)
     paths = fm.getpaths(_options, "lookback")
     mock_getpaths_fromlookback.assert_called_with(_options.input_prefix,
                                                   int(_options.lookback))
コード例 #2
0
    def test_get_paths_fromdir(self, mock_getpaths_fromdir):
        src_keys = ["directory"]
        for src in src_keys:
            self._options_dict.update({src: "foo"})
        _options = Bunch(**self._options_dict)

        paths = fm.getpaths(_options, "directory")
        mock_getpaths_fromdir.assert_called_with(_options.input_prefix,
                                                 _options.directory)
コード例 #3
0
    def test_get_paths_y(self, mock_getpaths_fromymd):
        src_keys = ["year"]
        for src in src_keys:
            self._options_dict.update({src: "1"})
        _options = Bunch(**self._options_dict)

        paths = fm.getpaths(_options, "year")
        mock_getpaths_fromymd.assert_called_with(_options.input_prefix,
                                                 int(_options.year),
                                                 None, None)
コード例 #4
0
    def test_get_paths_fromfile(self, mock_getpaths_fromfile):
        src_keys = ["file"]
        for src in src_keys:
            self._options_dict.update({src: "foo"})
        _options = Bunch(**self._options_dict)

        with mock.patch("__builtin__.open", create=True) as mock_open:
            mock_open.return_value = mock.MagicMock(spec=file)
            paths = fm.getpaths(_options, "file")
            mock_getpaths_fromfile.assert_called_with(_options.input_prefix,
                                                      mock_open().__enter__())
コード例 #5
0
    def test_get_paths_fromwindow(self, mock_getpaths_fromwindow):
        src_keys = ["window"]
        for src in src_keys:
            self._options_dict.update({src: "20"})
        _options = Bunch(**self._options_dict)

        with mock.patch("filemerge.filemerge.datetime.datetime") as mock_dt:
            mock_dt.now.date.return_value = "foo"
            paths = fm.getpaths(_options, "window")
            mock_getpaths_fromwindow.assert_called_with(_options.input_prefix,
                                                        int(_options.window),
                                                        mock_dt.now().date())
コード例 #6
0
 def test_get_paths_exception(self):
     _options_dict = dict.fromkeys(OPTIONS_KEYS)
     _options = Bunch(**_options_dict)
     with self.assertRaises(RuntimeError) as rte:
         paths = fm.getpaths(_options, "foo")