Ejemplo n.º 1
0
    def test_file_exists_for_missing_file(self, credentials):
        """Test RACKSPACE UPLOADER file_exists returns False if the file does not exist"""
        with patch('pybossa.uploader.rackspace.pyrax.cloudfiles') as mycf:
            u = RackspaceUploader()
            u.init_app(self.flask_app)
            container = MagicMock()
            container.get_object.side_effect = NoSuchObject
            mycf.get_container.return_value = container
            file_exists = u.file_exists('noexist.txt', 'mycontainer')

            mycf.get_container.assert_called_with('mycontainer')
            assert file_exists is False
Ejemplo n.º 2
0
    def test_file_exists_for_missing_file(self, credentials):
        """Test RACKSPACE UPLOADER file_exists returns False if the file does not exist"""
        with patch('pybossa.uploader.rackspace.pyrax.cloudfiles') as mycf:
            u = RackspaceUploader()
            u.init_app(self.flask_app)
            container = MagicMock()
            container.get_object.side_effect = NoSuchObject
            mycf.get_container.return_value = container
            file_exists = u.file_exists('noexist.txt', 'mycontainer')

            mycf.get_container.assert_called_with('mycontainer')
            assert file_exists is False
Ejemplo n.º 3
0
    def test_file_exists_for_real_file(self, credentials):
        """Test RACKSPACE UPLOADER file_exists returns True if the file exists"""
        with patch('pybossa.uploader.rackspace.pyrax.cloudfiles') as mycf:
            u = RackspaceUploader()
            u.init_app(self.flask_app)
            filename='test.jpg'
            container = MagicMock()
            container.get_object.return_value = "Real File"
            mycf.get_container.return_value = container
            file_exists = u.file_exists(filename, 'mycontainer')

            mycf.get_container.assert_called_with('mycontainer')
            container.get_object.assert_called_with(filename)
            assert file_exists is True
Ejemplo n.º 4
0
    def test_file_exists_for_real_file(self, credentials):
        """Test RACKSPACE UPLOADER file_exists returns True if the file exists"""
        with patch('pybossa.uploader.rackspace.pyrax.cloudfiles') as mycf:
            u = RackspaceUploader()
            u.init_app(self.flask_app)
            filename='test.jpg'
            container = MagicMock()
            container.get_object.return_value = "Real File"
            mycf.get_container.return_value = container
            file_exists = u.file_exists(filename, 'mycontainer')

            mycf.get_container.assert_called_with('mycontainer')
            container.get_object.assert_called_with(filename)
            assert file_exists is True