Ejemplo n.º 1
0
    def test_ack(self):
        self.instance._process_tuple(self.TICK)
        self.instance._process_tuple(self.TUPLE)

        self.mock_ack.assert_has_calls([
            mock.call(self.TICK),
            mock.call(self.TUPLE),
        ])
Ejemplo n.º 2
0
 def test__copy_dir_content(
         self, mock_copy2, mock_copytree, mock_isdir, mock_cont_to_copy):
     mock_cont_to_copy.return_value = ["foo/ham", "foo/honey"]
     mock_isdir.side_effect = iter([True, False])
     build._copy_dir_content(src="foo", dst="bar", exclude=[])
     mock_cont_to_copy.assert_called_once_with("foo", [])
     expected = [mock.call("foo/ham"), mock.call("foo/honey")]
     mock_isdir.assert_has_calls(expected)
     mock_copytree.assert_called_once_with(
         "foo/ham", "bar/ham", symlinks=True)
     mock_copy2.assert_called_once_with("foo/honey", "bar")
Ejemplo n.º 3
0
 def test__zip_dir(self, mock_walk):
     mock_arc = mock.Mock(autospec=True)
     mock_walk.return_value = [("foo", ["bar"], ["baz"]),
                               ("foo/bar", [], ["qux"])]
     build._zip_dir("foo", mock_arc)
     mock_walk.assert_any_call("foo")
     expected = [
         mock.call("foo/baz", "baz", zipfile.ZIP_DEFLATED),
         mock.call("foo/bar/qux", "bar/qux", zipfile.ZIP_DEFLATED),
     ]
     mock_arc.write.assert_has_calls(expected)
Ejemplo n.º 4
0
 def test__copy_dir_content(self, mock_copy2, mock_copytree, mock_isdir,
                            mock_cont_to_copy):
     mock_cont_to_copy.return_value = ["foo/ham", "foo/honey"]
     mock_isdir.side_effect = iter([True, False])
     build._copy_dir_content(src="foo", dst="bar", exclude=[])
     mock_cont_to_copy.assert_called_once_with("foo", [])
     expected = [mock.call("foo/ham"), mock.call("foo/honey")]
     mock_isdir.assert_has_calls(expected)
     mock_copytree.assert_called_once_with("foo/ham",
                                           "bar/ham",
                                           symlinks=True)
     mock_copy2.assert_called_once_with("foo/honey", "bar")
Ejemplo n.º 5
0
 def test__zip_dir(self, mock_walk):
     mock_arc = mock.Mock(autospec=True)
     mock_walk.return_value = [
         ("foo", ["bar"], ["baz"]),
         ("foo/bar", [], ["qux"])
     ]
     build._zip_dir("foo", mock_arc)
     mock_walk.assert_any_call("foo")
     expected = [
         mock.call("foo/baz", "baz", zipfile.ZIP_DEFLATED),
         mock.call("foo/bar/qux", "bar/qux", zipfile.ZIP_DEFLATED),
     ]
     mock_arc.write.assert_has_calls(expected)
Ejemplo n.º 6
0
 def test__set_up_virtualenv_without_requirements(self, mock_venv,
                                                  mock_remove_base_jar):
     venv = mock_venv.return_value
     build._set_up_virtualenv(
         venv_name="foo",
         tmp_dir="bar",
         req=None,
         include_packages=["fruit", "ninja==7.7.7"],
         system_site_packages=True,
         pypi_index_url="http://pypi-ninja.ninjacorp.com/simple",
         python_interpreter="python2.7",
         verbose=False)
     expected_install = [
         mock.call("pyleus=={0}".format(__version__)),
         mock.call("fruit"),
         mock.call("ninja==7.7.7")
     ]
     venv.install_package.assert_has_calls(expected_install)
     assert venv.install_from_requirements.call_count == 0
     mock_remove_base_jar.assert_called_once_with(venv)
Ejemplo n.º 7
0
 def test__set_up_virtualenv_without_requirements(self, mock_venv,
                                                  mock_remove_base_jar):
     venv = mock_venv.return_value
     build._set_up_virtualenv(
         venv_name="foo",
         tmp_dir="bar",
         req=None,
         include_packages=["fruit", "ninja==7.7.7"],
         system_site_packages=True,
         pypi_index_url="http://pypi-ninja.ninjacorp.com/simple",
         python_interpreter="python2.7",
         verbose=False)
     expected_install = [
         mock.call("pyleus=={0}".format(__version__)),
         mock.call("fruit"),
         mock.call("ninja==7.7.7")
     ]
     venv.install_package.assert_has_calls(expected_install)
     assert venv.install_from_requirements.call_count == 0
     mock_remove_base_jar.assert_called_once_with(venv)
Ejemplo n.º 8
0
 def test_expand_path(self, mock_path):
     mock_path.abspath.return_value = "bar"
     expanded = utils.expand_path("foo")
     mock_path.abspath.assert_has_calls(
         [mock.call(mock_path.expanduser("foo"))])
     assert expanded == "bar"
Ejemplo n.º 9
0
 def test_expand_path(self, mock_path):
     mock_path.abspath.return_value = "bar"
     expanded = utils.expand_path("foo")
     mock_path.abspath.assert_has_calls([
         mock.call(mock_path.expanduser("foo"))])
     assert expanded == "bar"