def test_get_artifact(self, _LocalRepository): _repo = mock.Mock(spec=LocalRepository) _repo.exists.side_effect = [True, False] _repo.open.return_value = StringIO("some data") _LocalRepository.return_value = _repo client = MavenClient("/maven") actual = client.get_artifact("foo:bar:2.0.0") assert "some data" == actual.contents.read() _repo.exists.assert_called_with("foo/bar/2.0.0/bar-2.0.0.jar") _repo.open.assert_called_with("foo/bar/2.0.0/bar-2.0.0.jar") _repo.reset_mock() self.assertRaises(MissingArtifactError, client.get_artifact, "foo:bar:3.0") _repo.exists.assert_called_with("foo/bar/3.0/bar-3.0.jar") _repo.open.assert_not_called() _repo.reset_mock() self.assertRaises(AssertionError, client.get_artifact, "foo:bar:[1.0,2.0]") _repo.open.assert_not_called()
def test_get_artifact(self, _LocalRepository): _repo = mock.Mock(spec=LocalRepository) _repo.exists.side_effect = [True, False] _repo.open.return_value = StringIO("some data") _LocalRepository.return_value = _repo client = MavenClient("/maven") actual = client.get_artifact("foo:bar:2.0.0") assert "some data" == actual.contents.read() _repo.exists.assert_called_with("foo/bar/2.0.0/bar-2.0.0.jar") _repo.open.assert_called_with("foo/bar/2.0.0/bar-2.0.0.jar") _repo.reset_mock() self.assertRaises(MissingArtifactError, client.get_artifact, "foo:bar:3.0") _repo.exists.assert_called_with("foo/bar/3.0/bar-3.0.jar") _repo.open.assert_not_called() _repo.reset_mock() self.assertRaises(AssertionError, client.get_artifact, "foo:bar:[1.0,2.0]") _repo.open.assert_not_called()
def test_get_artifact(self, _LocalRepository): _repo = mock.Mock(spec=LocalRepository) _repo.exists.side_effect = [True] _repo.open.return_value = StringIO("some data") _LocalRepository.return_value = _repo client = MavenClient("/maven") actual = client.get_artifact("foo:bar:2.0.0") assert "some data" == actual.contents.read() _repo.exists.assert_called_with("foo/bar/2.0.0/bar-2.0.0.jar") _repo.open.assert_called_with("foo/bar/2.0.0/bar-2.0.0.jar")