Esempio n. 1
3
    def test_build_fail_no_spec_or_src(self):
        with pytest.raises(SystemExit):
            t_config = TConfig()
            t_config.DATA_DIR = os.getcwd()
            pyu = PyUpdater(t_config)
            pyu.setup()
            build_cmd = ['build', '--app-name', 'MyApp', '--clean'
                         '--app-version', '0.1.0', '-F']

            parser = get_parser()
            args, pyu_args = parser.parse_known_args(build_cmd)
            b = Builder(args, pyu_args)
            b.build()
Esempio n. 2
0
    def test_make_spec(self):
        t_config = TConfig()
        t_config.DATA_DIR = os.getcwd()
        pyu = PyUpdater(t_config)
        pyu.setup()

        spec_cmd = ['make-spec', 'app.py', '-F', '--app-name', 'MyApp',
                    '--app-version', '0.1.0']
        spec_file_name = get_system() + '.spec'
        build_cmd = ['build', '--app-name', 'MyApp',
                     '--app-version', '0.1.0', spec_file_name]

        build_cmd = [str(b) for b in build_cmd]
        parser = get_parser()
        with open('app.py', 'w') as f:
            f.write('print "Hello, World!"')
        args, pyu_args = parser.parse_known_args(spec_cmd)
        b = Builder(args, pyu_args)
        b.make_spec()
        assert os.path.exists(spec_file_name)
        args, pyu_args = parser.parse_known_args(build_cmd)
        b = Builder(args, pyu_args)
        b.build()
        with ChDir(new_folder):
            assert len(os.listdir(os.getcwd())) == 1
Esempio n. 3
0
    def test_make_spec(self):
        t_config = TConfig()
        t_config.DATA_DIR = os.getcwd()
        pyu = PyUpdater(t_config)
        pyu.setup()

        spec_cmd = [
            'make-spec', 'app.py', '-F', '--app-name', 'MyApp',
            '--app-version', '0.1.0'
        ]
        spec_file_name = get_system() + '.spec'
        build_cmd = [
            'build', '--app-name', 'MyApp', '--app-version', '0.1.0',
            spec_file_name
        ]

        build_cmd = [str(b) for b in build_cmd]
        parser = get_parser()
        with open('app.py', 'w') as f:
            f.write('print "Hello, World!"')
        args, pyu_args = parser.parse_known_args(spec_cmd)
        b = Builder(args, pyu_args)
        b.make_spec()
        assert os.path.exists(spec_file_name)
        args, pyu_args = parser.parse_known_args(build_cmd)
        b = Builder(args, pyu_args)
        b.build()
        with ChDir(new_folder):
            assert len(os.listdir(os.getcwd())) == 1
Esempio n. 4
0
 def test_bad_pub_key(self):
     t_config = TConfig()
     # If changed ensure it's a valid key format
     t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM'
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     assert client.update_check(client.app_name, '0.0.0') is None
Esempio n. 5
0
 def test_bad_pub_key(self):
     t_config = TConfig()
     # If changed ensure it's a valid key format
     t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM'
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     assert client.update_check(client.app_name, '0.0.0') is None
def test_set_uploader_bad_settings():
    config = TConfig()
    config.ACCESS_KEY_ID = None
    config.SECRET_ACCESS_KEY = u'Not an actual secret'
    config.BUCKET_NAME = u'Bucket Name'
    s_nst = PyiUpdater(config)
    uploader = Uploader(s_nst)
    uploader.set_uploader(u's3')
def test_set_uploader_bad_settings():
    config = TConfig()
    config.ACCESS_KEY_ID = None
    config.SECRET_ACCESS_KEY = u'Not an actual secret'
    config.BUCKET_NAME = u'Bucket Name'
    s_nst = PyiUpdater(config)
    uploader = Uploader(s_nst)
    uploader.set_uploader(u's3')
Esempio n. 8
0
 def test_no_patch_support(self, db):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = TransistionDict()
     config.from_object(t_config)
     p = PackageHandler(config, db)
     p.process_packages()
Esempio n. 9
0
 def test_init(self, db):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     config = TransistionDict()
     config.from_object(t_config)
     p = PackageHandler(config, db)
     assert p.files_dir == os.path.join(data_dir, s_dir, 'files')
     assert p.deploy_dir == os.path.join(data_dir, s_dir, 'deploy')
Esempio n. 10
0
 def test_manifest_filesystem(self):
     t_config = TConfig()
     t_config.PUBLIC_KEYS = ['bad key']
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     filesystem_data = client._get_manifest_filesystem()
     filesystem_data = json.loads(filesystem_data)
     del filesystem_data['sigs']
     assert client.json_data == filesystem_data
 def test_process_packages(self):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = Config()
     config.from_object(t_config)
     p = PackageHandler(config)
     p.process_packages()
 def test_init(self):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     config = Config()
     config.from_object(t_config)
     p = PackageHandler(config)
     assert p.files_dir == os.path.join(data_dir, s_dir, 'files')
     assert p.deploy_dir == os.path.join(data_dir, s_dir, 'deploy')
Esempio n. 13
0
 def test_process_packages(self):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = Config()
     config.from_object(t_config)
     p = PackageHandler(config)
     p.process_packages()
Esempio n. 14
0
 def test_init(self):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     config = Config()
     config.from_object(t_config)
     p = PackageHandler(config)
     assert p.files_dir == os.path.join(data_dir, user_data_dir, "files")
     assert p.deploy_dir == os.path.join(data_dir, user_data_dir, "deploy")
Esempio n. 15
0
 def test_http(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.app_name == 'Acme'
     assert update.download() is True
     assert update.is_downloaded() is True
Esempio n. 16
0
 def test_http(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.app_name == 'Acme'
     assert update.download() is True
     assert update.is_downloaded() is True
Esempio n. 17
0
 def test_no_patch_support(self, db):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = TransistionDict()
     config.from_object(t_config)
     p = PackageHandler(config, db)
     p.process_packages()
Esempio n. 18
0
 def test_manifest_filesystem(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     filesystem_data = client._get_manifest_from_disk()
     assert filesystem_data is not None
     filesystem_data = filesystem_data.decode()
     filesystem_data = json.loads(filesystem_data)
     del filesystem_data["signature"]
     assert client.json_data == filesystem_data
Esempio n. 19
0
 def test_http(client):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     t_config.VERIFY_SERVER_CERT = False
     client = Client(t_config, refresh=True, test=True)
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.app_name == 'jms'
     assert update.download() is True
     assert update.is_downloaded() is True
Esempio n. 20
0
 def test_manifest_filesystem(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     filesystem_data = client._get_manifest_filesystem()
     assert filesystem_data is not None
     if six.PY3:
         filesystem_data = filesystem_data.decode()
     filesystem_data = json.loads(filesystem_data)
     del filesystem_data['signature']
     assert client.json_data == filesystem_data
 def test_directory_creation(self):
     data_dir = os.getcwd()
     pyu_data_dir = os.path.join(data_dir, 'pyu-data')
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     pyu = PyUpdater(t_config)
     pyu.setup()
     assert os.path.exists(pyu_data_dir)
     assert os.path.exists(os.path.join(pyu_data_dir, 'deploy'))
     assert os.path.exists(os.path.join(pyu_data_dir, 'files'))
     assert os.path.exists(os.path.join(pyu_data_dir, 'new'))
Esempio n. 22
0
    def test_callback(self):
        def cb(status):
            print(status)

        def cb2(status):
            raise IndexError

        t_config = TConfig()
        t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM'
        t_config.DATA_DIR = os.getcwd()
        client = Client(t_config, refresh=True, test=True, progress_hooks=[cb])
        client.add_progress_hook(cb2)
        assert client.update_check(client.app_name, '0.0.0') is None
Esempio n. 23
0
    def test_callback(self):
        def cb(status):
            print(status)

        def cb2(status):
            raise IndexError

        t_config = TConfig()
        t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM'
        t_config.DATA_DIR = os.getcwd()
        client = Client(t_config, refresh=True, test=True, progress_hooks=[cb])
        client.add_progress_hook(cb2)
        assert client.update_check(client.app_name, '0.0.0') is None
Esempio n. 24
0
    def test_callback(self):
        def cb(status):
            print(status)

        def cb2(status):
            raise IndexError

        t_config = TConfig()
        t_config.PUBLIC_KEYS = ['bad key']
        t_config.DATA_DIR = os.getcwd()
        client = Client(t_config, refresh=True, test=True, call_back=cb,
                        callbacks=[cb, cb2])
        client.add_call_back(cb2)
        assert client.update_check('jms', '0.0.0') is None
Esempio n. 25
0
    def test_build_fail_no_spec_or_src(self):
        with pytest.raises(SystemExit):
            t_config = TConfig()
            t_config.DATA_DIR = os.getcwd()
            pyu = PyUpdater(t_config)
            pyu.setup()
            build_cmd = [
                'build', '--app-name', 'MyApp', '--clean'
                '--app-version', '0.1.0', '-F'
            ]

            parser = get_parser()
            args, pyu_args = parser.parse_known_args(build_cmd)
            b = Builder(args, pyu_args)
            b.build()
Esempio n. 26
0
 def test_async_http(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.app_name == 'Acme'
     update.download(async=True)
     count = 0
     while count < 61:
         if update.is_downloaded() is True:
             break
         time.sleep(1)
         count += 1
     assert update.is_downloaded() is True
Esempio n. 27
0
 def test_background_http(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.app_name == 'Acme'
     update.download(background=True)
     count = 0
     while count < 61:
         if update.is_downloaded() is True:
             break
         time.sleep(1)
         count += 1
     assert update.is_downloaded() is True
Esempio n. 28
0
def test_original_init():
    config = TConfig()
    updater = PyiUpdater(config)
    client = Client(updater, test=True)
    assert client.app_name == u'jms'
    assert client.update_urls[0] == (u'https://s3-us-west-1.amazon'
                                     'aws.com/pyi-test/')
Esempio n. 29
0
    def test_build_mac_dot_app(self):
        t_config = TConfig()
        t_config.DATA_DIR = os.getcwd()
        pyu = PyUpdater(t_config)
        pyu.setup()

        build_cmd = ['build', '-F', '-w', '--app-name', 'MyApp',
                     '--app-version', '0.1.0', 'app.py']
        build_cmd = [str(b) for b in build_cmd]
        parser = get_parser()
        with open('app.py', 'w') as f:
            f.write('print "Hello, World!"')
        args, pyu_args = parser.parse_known_args(build_cmd)
        b = Builder(args, pyu_args)
        b.build()
        with ChDir(new_folder):
            assert len(os.listdir(os.getcwd())) == 1
Esempio n. 30
0
    def test_build(self):
        t_config = TConfig()
        t_config.DATA_DIR = os.getcwd()
        pyu = PyUpdater(t_config)
        pyu.setup()

        build_cmd = [
            'build', '--app-name', 'MyApp', '--app-version', '0.1.0', 'app.py'
        ]
        build_cmd = [str(b) for b in build_cmd]
        parser = get_parser()
        with open('app.py', 'w') as f:
            f.write('print "Hello, World!"')
        args, pyu_args = parser.parse_known_args(build_cmd)
        b = Builder(args, pyu_args)
        b.build()
        with ChDir(new_folder):
            assert len(os.listdir(os.getcwd())) == 1
Esempio n. 31
0
 def test_multiple_background_calls(self, client):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     t_config.VERIFY_SERVER_CERT = False
     client = Client(t_config, refresh=True, test=True)
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.app_name == 'Acme'
     update.download(background=True)
     count = 0
     assert update.download(background=True) is None
     assert update.download() is None
     while count < 61:
         if update.is_downloaded() is True:
             break
         time.sleep(1)
         count += 1
     assert update.is_downloaded() is True
Esempio n. 32
0
 def test_multipule_async_calls(self, client):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     t_config.VERIFY_SERVER_CERT = False
     client = Client(t_config, refresh=True, test=True)
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.app_name == 'Acme'
     update.download(async=True)
     count = 0
     assert update.download(async=True) is None
     assert update.download() is None
     while count < 61:
         if update.is_downloaded() is True:
             break
         time.sleep(1)
         count += 1
     assert update.is_downloaded() is True
Esempio n. 33
0
def setup_func():
    global test_data_dir

    config = TConfig()
    updater = PyiUpdater(config)
    ph = PackageHandler(updater)
    kh = KeyHandler(updater)
    kh.test = True
    ph.setup()
    kh.make_keys()
Esempio n. 34
0
    def test_build_fail_script_syntax_error(self):
        with pytest.raises(SystemExit):
            t_config = TConfig()
            t_config.DATA_DIR = os.getcwd()
            pyu = PyUpdater(t_config)
            pyu.setup()
            spec_cmd = ['make-spec', 'app.py', '-F']
            spec_file_name = get_system() + '.spec'
            build_cmd = ['build', '--app-name', 'MyApp', '--clean'
                         '--app-version', '0.1.0', spec_file_name]

            parser = get_parser()
            with open('app.py', 'w') as f:
                # Missing closing quote
                f.write('print "Hello, World!')
            args, pyu_args = parser.parse_known_args(spec_cmd)
            b = Builder(args, pyu_args)
            b.make_spec()
            assert os.path.exists(spec_file_name)
            args, pyu_args = parser.parse_known_args(build_cmd)
            b = Builder(args, pyu_args)
Esempio n. 35
0
def test_setup():
    global test_data_dir

    config = TConfig()
    updater = PyiUpdater(config)
    ph = PackageHandler(updater)
    key_dir = os.path.join(ph.data_dir, u'keys')

    kh = KeyHandler(updater)
    kh.test = True
    assert os.path.exists(os.path.abspath(key_dir))
    assert kh.private_key_name == u'jms.pem'
    assert kh.public_key_name == u'jms.pub'
Esempio n. 36
0
    def test_build_fail_script_syntax_error(self):
        with pytest.raises(SystemExit):
            t_config = TConfig()
            t_config.DATA_DIR = os.getcwd()
            pyu = PyUpdater(t_config)
            pyu.setup()
            spec_cmd = ['make-spec', 'app.py', '-F']
            spec_file_name = get_system() + '.spec'
            build_cmd = [
                'build', '--app-name', 'MyApp', '--clean'
                '--app-version', '0.1.0', spec_file_name
            ]

            parser = get_parser()
            with open('app.py', 'w') as f:
                # Missing closing quote
                f.write('print "Hello, World!')
            args, pyu_args = parser.parse_known_args(spec_cmd)
            b = Builder(args, pyu_args)
            b.make_spec()
            assert os.path.exists(spec_file_name)
            args, pyu_args = parser.parse_known_args(build_cmd)
            b = Builder(args, pyu_args)
Esempio n. 37
0
def test_execution():
    global test_data_dir

    config = TConfig()
    updater = PyiUpdater(config)
    ph = PackageHandler(updater)
    kh = KeyHandler(updater)

    ph.setup()
    kh.test = True
    kh.make_keys()

    # Make zipfile
    with ChDir(test_data_dir):
        os.mkdir(u'test-app')
        with ChDir(u'test-app'):
            with open(u'app.txt', u'w') as f:
                f.write(u'I am so happy' * 1000)
        shutil.make_archive(u'Test App-mac-0.2.0', u'zip', u'test-app')
        shutil.move(u'Test App-mac-0.2.0.zip', u'new')
    ph.process_packages()
    kh.sign_update()
Esempio n. 38
0
def pyu():
    t_config = TConfig()
    t_config.DATA_DIR = os.getcwd()
    pyu = PyUpdater(t_config)
    return pyu
Esempio n. 39
0
 def test_bad_pub_key(self, client):
     t_config = TConfig()
     t_config.PUBLIC_KEYS = ['bad key']
     t_config.DATA_DIR = os.getcwd()
     client = Client(t_config, refresh=True, test=True)
     assert client.update_check('jms', '0.0.0') is None
Esempio n. 40
0
def test_check_version():
    config = TConfig()
    client = Client(config, test=True)
    assert client.update_check(client.app_name, '0.0.2') is True
    assert client.update_check(client.app_name, '6.0.0') is False
def test_dev_dir_none():
    updater = PyiUpdater(__name__)
    myconfig = TConfig()
    myconfig.APP_NAME = None
    updater.update_config(myconfig)
    assert updater.config[u'APP_NAME'] == u'PyiUpdater App'
Esempio n. 42
0
 def test_url_list_attr(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     t_config.UPDATE_URL = ['http://acme.com/update']
     client = Client(t_config, refresh=True, test=True)
     assert isinstance(client.update_urls, list)
Esempio n. 43
0
 def test_urls_tuple_attr(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     t_config.UPDATE_URLS = ('http://acme.com/update')
     client = Client(t_config, test=True)
     assert isinstance(client.update_urls, list)
Esempio n. 44
0
def test_data_dir():
    client = Client(TConfig(), test=True)
    assert os.path.exists(client.data_dir) is True
Esempio n. 45
0
 def test_url_str_attr(self):
     t_config = TConfig()
     t_config.DATA_DIR = os.getcwd()
     t_config.UPDATE_URLS = 'http://acme.com/update'
     client = Client(t_config, test=True)
     assert isinstance(client.update_urls, list)
Esempio n. 46
0
def client():
    t_config = TConfig()
    t_config.DATA_DIR = os.getcwd()
    client = Client(t_config, refresh=True, test=True)
    client.FROZEN = True
    return client
Esempio n. 47
0
def pyu():
    t_config = TConfig()
    t_config.DATA_DIR = os.getcwd()
    pyu = PyUpdater(t_config)
    return pyu
Esempio n. 48
0
def test_download():
    client = Client(TConfig(), test=True)
    assert client.app_name == u'jms'
    assert client.update_check(client.app_name, '0.0.1') is True
    assert client.download() is True
    assert client.install() is True
Esempio n. 49
0
def client():
    t_config = TConfig()
    t_config.DATA_DIR = os.getcwd()
    client = Client(t_config, refresh=True, test=True)
    client.FROZEN = True
    return client
Esempio n. 50
0
import os
import shutil
import sys

from nose import with_setup

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from pyi_updater import PyiUpdater
from pyi_updater.client import Client
from tconfig import TConfig

client = Client(TConfig(), test=True)


def tear_down():
    if os.path.exists(client.data_dir):
        shutil.rmtree(client.data_dir, ignore_errors=True)


def test_data_dir():
    client = Client(TConfig(), test=True)
    assert os.path.exists(client.data_dir) is True


def test_original_init():
    config = TConfig()
    updater = PyiUpdater(config)
    client = Client(updater, test=True)
    assert client.app_name == u'jms'
    assert client.update_urls[0] == (u'https://s3-us-west-1.amazon'
Esempio n. 51
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# --------------------------------------------------------------------------
from __future__ import unicode_literals

import pytest
import requests

from pyupdater.uploader import BaseUploader, Uploader
from pyupdater.utils.exceptions import UploaderError, UploaderPluginError

from tconfig import TConfig

my_config = TConfig()


@pytest.mark.usefixtures('cleandir')
class TestUtils(object):
    def test_plugin_baseclass_not_implemented(self):

        with pytest.raises(NotImplementedError):
            b = BaseUploader()
            b.init()

        with pytest.raises(NotImplementedError):
            b = BaseUploader()
            b.connect()

        with pytest.raises(NotImplementedError):
Esempio n. 52
0
def test_new_init():
    config = TConfig()
    client = Client(config, test=True)
    assert client.app_name == u'jms'
    assert client.update_urls[0] == (u'https://s3-us-west-1.amazon'
                                     'aws.com/pyi-test/')
Esempio n. 53
0
 def test_dev_dir_none(self):
     myconfig = TConfig()
     myconfig.APP_NAME = None
     updater = TransistionDict()
     updater.from_object(myconfig)
     assert updater['APP_NAME'] == 'PyUpdater App'
Esempio n. 54
0
def test_bad_pub_key():
    config = TConfig()
    config.PUBLIC_KEY = 'bad key'
    client = Client(config, test=True)
    assert client.update_check(u'jms', '0.0.0') is False