예제 #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()
예제 #2
0
    def test_execution(self, pyu, db):
        archive_name = 'myapp-{}-0.1.0{}'.format(get_system(), ext)
        parser = get_parser()
        data_dir = pyu.config['DATA_DIR']
        pyu_data_dir = os.path.join(data_dir, 'pyu-data')
        pyu.setup()
        pyu.make_keys(3)
        with ChDir(data_dir):
            loader = Loader(db)
            loader.save_config(pyu.config.copy())
            with open('app.py', 'w') as f:
                f.write('print "Hello World"')
            args, pyu_args = parser.parse_known_args(create_build_cmd(0))
            b = Builder(args, pyu_args)
            b.build()

        assert os.path.exists(os.path.join(pyu_data_dir, 'new',
                              archive_name))
        pyu.process_packages()
        assert os.path.exists(os.path.join(pyu_data_dir, 'deploy',
                              archive_name))
        assert os.path.exists(os.path.join(pyu_data_dir, 'files',
                              archive_name))
        pyu.sign_update()
        assert os.path.exists(os.path.join(pyu_data_dir, 'deploy',
                              'versions.gz'))
예제 #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
예제 #4
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
예제 #5
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()
예제 #6
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
예제 #7
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
예제 #8
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)
예제 #9
0
def _real_main(args):  # pragma: no cover
    if args is None:
        args = sys.argv[1:]
    parser = get_parser()
    args, pyi_args = parser.parse_known_args(args)
    cmd = args.command
    if cmd == 'archive':
        archive(args)
    elif cmd == 'build':
        _build(args, pyi_args)
    elif cmd == 'clean':
        clean(args)
    elif cmd == 'init':
        init(args)
    elif cmd == 'keys':
        keys(args)
    # ToDo: Remove in v1.0
    elif cmd == 'log':
        warnings.simplefilter('always', DeprecationWarning)
        warnings.warn('Use "collect-debug-info" ', DeprecationWarning)
        upload_debug_info(args)
    # End to do
    elif cmd == 'collect-debug-info':
        upload_debug_info(args)
    elif cmd == 'make-spec':
        _make_spec(args, pyi_args)
    elif cmd == 'pkg':
        pkg(args)
    elif cmd == 'settings':
        _setting(args)
    elif cmd == 'update':
        update(args)
    elif cmd == 'upload':
        upload(args)
    elif cmd == 'version':
        print('PyUpdater {}'.format(__version__))
    else:
        log.error('Not Implemented')
        sys.exit(1)
예제 #10
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)
예제 #11
0
def _real_main(args):  # pragma: no cover
    if args is None:
        args = sys.argv[1:]
    parser = get_parser()
    args, pyi_args = parser.parse_known_args(args)
    cmd = args.command
    if cmd == 'build':
        _build(args, pyi_args)
    elif cmd == 'clean':
        clean(args)
    elif cmd == 'init':
        init(args)
    elif cmd == 'keys':
        keys(args)
    # ToDo: Remove in v1.0
    elif cmd == 'log':
        warnings.simplefilter('always', DeprecationWarning)
        warnings.warn('Use "collect-debug-info" ', DeprecationWarning)
        upload_debug_info(args)
    # End to do
    elif cmd == 'collect-debug-info':
        upload_debug_info(args)
    elif cmd == 'make-spec':
        _make_spec(args, pyi_args)
    elif cmd == 'pkg':
        pkg(args)
    elif cmd == 'settings':
        _setting(args)
    elif cmd == 'update':
        update(args)
    elif cmd == 'upload':
        upload(args)
    elif cmd == 'version':
        print('PyUpdater {}'.format(__version__))
    else:
        log.error('Not Implemented')
        sys.exit(1)