Exemplo n.º 1
0
def given_a_populated_project(t: env.Env):
    """show formatted total storage value and entity count"""
    prj = preset.project_created(t)

    ds1 = preset.dataset_created(t, prj)
    ds2 = preset.dataset_created(t, prj)

    ver = preset.dataset_version_added(t, ds1)

    del ver.items[:]
    ver.items.append(
        vo.DatasetItem(name='file',
                       storage_bytes=3000,
                       records=2,
                       uid=t.next_uid()))

    t.given_events(
        prj,
        ds1,
        ds2,
        preset.job_added(t, prj),
        preset.job_added(t, prj),
        preset.job_added(t, prj),
        ver,
    )

    t.scenario(
        when.list_projects(),
        then.text(f'main #prj-{prj.uid.hex()} .storage-size',
                  nbsp('3.0 kB'),
                  title='3000'),
        then.text(f'main #prj-{prj.uid.hex()} .dataset-count', "2"),
        then.text(f'main #prj-{prj.uid.hex()} .job-count', "3"))
def given_a_dataset_with_a_single_version(t: env.Env):
    """show formatted size on all screens"""
    prj = preset.project_created(t)
    ds = preset.dataset_created(t, prj)

    ver = preset.dataset_version_added(t, ds)
    del ver.items[:]
    ver.items.append(
        vo.DatasetItem(name='file',
                       storage_bytes=1100,
                       records=1,
                       uid=t.next_uid()))

    size = _avoid_wrapping('1.1 kB')
    title = "1100"

    t.given_events(prj, ds, ver)
    t.scenario(
        when.view_dataset(ds.project_name, ds.name),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', size, title=title),
    )

    t.scenario(
        when.list_datasets(),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', size, title=title),
    )

    t.scenario(
        when.view_project(prj.name),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', size, title=title),
    )
Exemplo n.º 3
0
def dataset_version_added(t: env.Env,
                          ds: evt.DatasetCreated,
                          v: evt.DatasetVersionAdded = None,
                          ts: timedelta = timedelta()):

    uid = t.next_uid()
    updated = t.time + ts
    ver = evt.DatasetVersionAdded(
        uid=uid,
        project_name=ds.project_name,
        dataset_uid=ds.uid,
        title=f'Version {uid.hex()}',
        items=[
            vo.DatasetItem(
                uid=t.next_uid(),
                name=
                f'{random.choice(nouns)}_{random.choice(verbs)}_{random.randint(0,100)}.tsv',
                storage_bytes=random.randint(1000, 1000000))
        ],
        project_uid=ds.project_uid,
        timestamp=int(updated.timestamp()),
    )

    if v:
        ver.parent_uid = v.uid
    return ver
def given_a_dataset_with_multiple_mutating_versions(t: env.Env):
    """show formatted size on all screens"""
    prj = preset.project_created(t)
    ds = preset.dataset_created(t, prj)

    v1 = preset.dataset_version_added(t, ds)
    del v1.items[:]
    item1 = vo.DatasetItem(name='file1',
                           storage_bytes=1100,
                           records=1,
                           uid=t.next_uid())
    item2 = vo.DatasetItem(name='file2',
                           storage_bytes=2200,
                           records=1,
                           uid=t.next_uid())

    v1.items.extend([item1, item2])

    v2 = preset.dataset_version_added(t, ds, v1)
    del v2.items[:]
    del v2.remove[:]

    v2.remove.append(item1)

    t.given_events(prj, ds, v1, v2)
    t.scenario(
        when.view_dataset(ds.project_name, ds.name),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', title="2200"),
    )

    t.scenario(
        when.list_datasets(),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', title="2200"),
    )

    t.scenario(
        when.view_project(prj.name),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', title="2200"),
    )
def given_a_dataset_with_multiple_additive_versions(t: env.Env):
    """render final size"""
    prj = preset.project_created(t)
    ds = preset.dataset_created(t, prj)

    v1 = preset.dataset_version_added(t, ds)
    del v1.items[:]
    v1.items.append(
        vo.DatasetItem(name='file1',
                       storage_bytes=1100,
                       records=1,
                       uid=t.next_uid()))

    v2 = preset.dataset_version_added(t, ds, v1)
    del v2.items[:]
    v2.items.append(
        vo.DatasetItem(name='file2',
                       storage_bytes=2200,
                       records=1,
                       uid=t.next_uid()))

    t.given_events(prj, ds, v1, v2)
    t.scenario(
        when.view_dataset(ds.project_name, ds.name),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', title="3300"),
    )

    t.scenario(
        when.list_datasets(),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', title="3300"),
    )

    t.scenario(
        when.view_project(prj.name),
        then.text(f'main #ds-{ds.uid.hex()} .zip-size', title="3300"),
    )
def given_a_datasets_with_various_storage_sizes(t: env.Env):
    """show formatted storage value"""
    prj = preset.project_created(t)

    map = {
        0: '0 bytes',
        1: '1 byte',
        1000: '1.0 kB',
        1000000: '1.0 MB',
        1100000: '1.1 MB',
        3000000000: '3.0 GB',
        4100000000000: '4.1 TB',
    }

    conditionals = []
    conditionals.append(when.list_datasets())

    t.given_events(prj)

    for k, v in map.items():
        ds = preset.dataset_created(t, prj)
        ver = preset.dataset_version_added(t, ds)

        del ver.items[:]
        ver.items.append(
            vo.DatasetItem(name='file',
                           storage_bytes=k,
                           records=1,
                           uid=t.next_uid()))

        value = _avoid_wrapping(v)
        conditionals.append(
            then.text(f'main #ds-{ds.uid.hex()} .zip-size', value), )
        t.given_events(ds, ver)

    t.scenario(*conditionals)