Esempio n. 1
0
def appdir(now):
    # We do not use the tmpdir_factory fixture because we use the files
    # produces by the tests to test QWatson locally.

    appdir = osp.join(osp.dirname(__file__), 'appdir',
                      'mainwindow_aposteriori')

    delete_folder_recursively(appdir)
    if not osp.exists(appdir):
        os.makedirs(appdir)

    # Create the projects file.

    with open(osp.join(appdir, 'projects'), 'w') as f:
        f.write(json.dumps(['p1', 'p2', 'p3']))

    # Create the frames file.

    frames = [[
        now.timestamp, now.timestamp, "p1", "e22fe653844442bab09a109f086688ec",
        ["tag1", "tag2", "tag3"], now.timestamp, "Base activity"
    ]]
    with open(osp.join(appdir, 'frames'), 'w') as f:
        f.write(json.dumps(frames))

    return appdir
def appdir(now, span, tmpdir):
    """Temporary app directory fixture that also creates a test Frame file."""

    appdir = osp.join(str(tmpdir), 'appdir')

    delete_folder_recursively(appdir)
    if not osp.exists(appdir):
        os.makedirs(appdir)

    # Create the frames file.

    frames = Frames()
    i = 1
    while True:
        frame = frames.add(project='p%d' % (i // 2),
                           start=span[0].shift(hours=i * 6).timestamp,
                           stop=span[0].shift(hours=(i + 1) * 6).timestamp,
                           message='activity #%d' % (i // 2),
                           tags=['CI', 'test', '#%d' % (i // 2)],
                           updated_at=now)
        if frame.stop >= span[1]:
            break
        i += 2

    with open(osp.join(appdir, 'frames'), 'w') as f:
        f.write(json.dumps(frames.dump(), indent=1, ensure_ascii=False))

    return appdir
Esempio n. 3
0
def test_accept_import_from_watson(qwatson_bot, newdir):
    """
    Test that the dialog to import settings and data from Watson the first
    time QWatson is started is working as expected when the import is
    accepted by the user.
    """
    delete_folder_recursively(newdir, delroot=True)
    qwatson, qtbot, mocker = qwatson_bot(qwatson_dir=newdir)

    # Assert that the import dialog it shown.

    assert qwatson.import_dialog is not None
    assert qwatson.import_dialog.isVisible()

    # Answer 'Import' in the import dialog and assert that the frames and that
    # the activity input dialog data.

    with qtbot.waitSignal(qwatson.import_dialog.destroyed):
        qtbot.mouseClick(qwatson.import_dialog.buttons['Import'],
                         Qt.LeftButton)

    assert qwatson.import_dialog is None
    assert qwatson.currentIndex() == 0

    table = qwatson.overview_widg.table_widg.tables[0]
    assert table.view.proxy_model.get_accepted_row_count() == 1

    assert len(qwatson.client.frames) == 1
    assert qwatson.currentProject() == 'p1'
    assert qwatson.tag_manager.tags == ['tag1', 'tag2', 'tag3']
    assert qwatson.comment_manager.text() == 'First activity'
Esempio n. 4
0
def appdir(now):
    # We do not use the tmpdir_factory fixture because we use the files
    # produces by the tests to test QWatson locally.

    appdir = osp.join(osp.dirname(__file__), 'appdir', 'mainwindow')
    delete_folder_recursively(appdir)
    if not osp.exists(appdir):
        os.makedirs(appdir)

    # Create the frames file.

    frames = [[
        round_arrow_to(now.shift(hours=-3), 5).timestamp,
        round_arrow_to(now,
                       5).timestamp, "p1", "e22fe653844442bab09a109f086688ec",
        ["tag1", "tag2", "tag3"], now.timestamp, "First activity"
    ]]
    with open(osp.join(appdir, 'frames'), 'w') as f:
        f.write(json.dumps(frames))

    return appdir
Esempio n. 5
0
def newdir(now):
    appdir_empty = osp.join(osp.dirname(__file__), 'appdir', 'new')
    delete_folder_recursively(appdir_empty)
    return appdir_empty
def appdir():
    # We do not use the tmpdir_factory fixture because we use the files
    # produces by the tests to test QWatson locally.
    appdir = osp.join(osp.dirname(__file__), 'appdir', 'mainwindow_project')
    delete_folder_recursively(appdir, delroot=True)
    return appdir