Пример #1
0
def test_build_widget_inexistent(tmpdir):
    p = tmpdir.join('db')
    shutil.copytree(os.path.join(FIXTURE_PATH, 'launchpad'), p.strpath)

    with pytest.raises(launchpad.LaunchpadValidationError):
        launchpad.build(widget_layout=[['Boo']],
                        app_layout=[],
                        launchpad_db_path=p.join('db').strpath)
Пример #2
0
def test_build_missing_folder_title(tmpdir):
    p = tmpdir.join('db')
    shutil.copytree(os.path.join(FIXTURE_PATH, 'launchpad'), p.strpath)

    with pytest.raises(launchpad.LaunchpadValidationError):
        launchpad.build(widget_layout=[[{
            'folder_layout': [['Unit Converter', 'Weather', 'Web Clip']]
        }]],
                        app_layout=[],
                        launchpad_db_path=p.join('db').strpath)
Пример #3
0
def test_build_missing_folder_layout(tmpdir):
    p = tmpdir.join('db')
    shutil.copytree(os.path.join(FIXTURE_PATH, 'launchpad'), p.strpath)

    with pytest.raises(launchpad.LaunchpadValidationError):
        launchpad.build(widget_layout=[],
                        app_layout=[[{
                            'folder_title': 'Unused Stuff'
                        }]],
                        launchpad_db_path=p.join('db').strpath)
Пример #4
0
def test_build_extract_roundtrip_path_unspecified(tmpdir, monkeypatch):
    p = tmpdir.join('db')
    shutil.copytree(os.path.join(FIXTURE_PATH, 'launchpad'), p.strpath)

    monkeypatch.setattr(launchpad, 'get_launchpad_db_path',
                        lambda: p.join('db').strpath)

    widget_layout = [
        # Page 1
        [
            'Dictionary', 'Calculator', 'Contacts', 'Calendar', 'Movies',
            'Stickies', 'Tile Game', 'Stocks', {
                'folder_title': 'Stuff',
                'folder_layout': [['Unit Converter', 'Weather', 'Web Clip']]
            }, 'World Clock'
        ]
    ]

    app_layout = [
        # Page 1
        [
            'Safari', 'Mail', 'Contacts', 'Calendar', 'Messages', 'FaceTime',
            'Photos', 'iTunes', 'iBooks', 'App Store', 'Preview', {
                'folder_title':
                'Unused Stuff',
                'folder_layout': [[
                    'Dictionary',
                    'Calculator',
                    'Reminders',
                    'Notes',
                    'Maps',
                    'Photo Booth',
                ]]
            }, {
                'folder_layout': [[
                    'QuickTime Player', 'TextEdit', 'Grapher', 'DVD Player',
                    'Time Machine', 'Font Book', 'Chess', 'Stickies',
                    'Image Capture', 'VoiceOver Utility', 'AirPort Utility',
                    'Migration Assistant', 'Terminal', 'Activity Monitor',
                    'Console', 'Keychain Access', 'System Information',
                    'Automator', 'Script Editor', 'Disk Utility',
                    'Boot Camp Assistant', 'Digital Color Meter',
                    'ColorSync Utility', 'Grab', 'Bluetooth File Exchange',
                    'Audio MIDI Setup'
                ]],
                'folder_title':
                'Other'
            }, 'Siri', 'System Preferences'
        ],
        # Page 2
        ['Mission Control', 'Dashboard'],
        # Page 3
        [{
            'folder_title': 'Productivity',
            'folder_layout': [['DaisyDisk', 'Entropy'], ['Things']]
        }, 'Spotify', 'Sublime Text']
    ]

    launchpad.build(widget_layout=widget_layout, app_layout=app_layout)

    assert launchpad.extract(p.join('db').strpath) == (widget_layout,
                                                       app_layout)