예제 #1
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_date_before_init(cleandir):
    root = c.init()

    time.sleep(0.2)
    c.ft_at_time(root, datetime.now() - timedelta(days=1))

    assert (Path() / '.cairo.pkl').exists()
예제 #2
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_change_file_back_in_time(cleandir):
    c.init()
    p = Path() / 'test_new.txt'
    p.touch()

    r = c.init()
    c.commit(r)

    r = c.init()
    v = c.get_versions(r)[0]

    p.write_text('change1')
    r = c.init()
    c.commit(r)

    r = c.init()
    vs = c.get_versions(r)
    vtime = vs[0].time
    before = v.time  #- timedelta(microseconds=1)
    after = v.time + timedelta(microseconds=10)

    r = c.init()
    c.ft_at_time(r, before)
    assert not p.read_text()

    p.write_text('change2')

    r = c.init()
    assert not c.changed_files(r)
예제 #3
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_remove_change_in_time(cleandir):
    root = c.init()
    p = Path() / 'test_dir' / 'test.txt'
    c.rm_file(root, p)

    vtime = c.get_versions(root)[-1].time
    before = vtime - timedelta(microseconds=10)
    after = vtime + timedelta(microseconds=10)

    c.ft_at_time(root, before)
    assert p.exists()

    c.ft_at_time(root, after)
    assert not p.exists()
예제 #4
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_path_change_in_time(cleandir):
    root = c.init()
    c.mv_file(root, Path() / 'test3.txt', Path() / 'test_dir')

    vtime = c.get_versions(root)[-1].time
    before = vtime - timedelta(microseconds=10)
    after = vtime + timedelta(microseconds=10)

    c.ft_at_time(root, before)
    assert (Path() / 'test3.txt').exists()
    assert not (Path() / 'test_dir' / 'test3.txt').exists()

    c.ft_at_time(root, after)
    assert not (Path() / 'test3.txt').exists()
    assert (Path() / 'test_dir' / 'test3.txt').exists()
예제 #5
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_add_dir_and_file_change_in_time(cleandir):
    c.init()
    d = Path() / 'new_dir'
    d.mkdir()
    p = d / 'new_file.txt'
    p.touch()

    root = c.init()
    c.commit(root)

    root = c.init()
    c.ft_at_time(root, datetime.now() - timedelta(days=1))

    root = c.init()
    assert not c.changed_files(root)

    root = c.init()
    c.ft_at_time(root, datetime.now())
    assert d.exists() and p.exists()
예제 #6
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_data_change_in_time(cleandir):
    root = c.init()
    p = Path() / 'test_dir' / 'test.txt'
    old_data = p.read_text()

    time.sleep(.02)
    p.write_text('change')

    c.commit(root)
    vtime = c.get_versions(root)[-1].time
    before = vtime - timedelta(microseconds=10)
    after = vtime + timedelta(microseconds=10)

    c.ft_at_time(root, before)
    data = p.read_text()
    assert data == old_data

    c.ft_at_time(root, after)
    data = p.read_text()
    assert data == "change"
예제 #7
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_add_file_change_in_time(cleandir):
    root = c.init()
    p = Path() / 'new_file.txt'
    p.touch()
    #root = c.init()
    c.commit(root)
    assert p.exists()

    before = datetime.now() - timedelta(days=1)
    after = datetime.now() + timedelta(days=1)
    #root = c.init()
    c.ft_at_time(root, before)
    assert not p.exists()
    #root = c.init()
    assert not c.changed_files(root)
    #root = c.init()
    c.ft_at_time(root, after)
    assert p.exists()
    #root = c.init()
    assert not c.changed_files(root)
예제 #8
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_commit_when_not_current(cleandir):
    c.init()
    d = Path() / 'new'
    d.mkdir()
    p = d / 'new_file.txt'
    p.touch()

    root = c.init()
    c.commit(root)
    vtime = c.get_versions(root)[-1].time
    before = vtime - timedelta(microseconds=10)

    root = c.init()
    c.ft_at_time(root, before)

    (Path() / 'test3.txt').write_text('changed')
    root = c.init()
    assert not c.changed_files(root)

    root = c.init()
    pytest.raises(c.CairoException, c.commit, root)
예제 #9
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_remove2_change_in_time(cleandir):
    c.init()
    p = Path() / 'test_dir' / 'test.txt'
    p.unlink()

    root = c.init()
    c.commit(root)

    vtime = c.get_versions(root)[-1].time
    before = vtime - timedelta(microseconds=1)
    after = vtime + timedelta(microseconds=10)

    root = c.init()
    c.ft_at_time(root, before)
    root = c.init()
    assert not c.changed_files(root)
    assert p.exists()

    root = c.init()
    c.ft_at_time(root, after)
    assert not p.exists()
예제 #10
0
파일: test_cairo.py 프로젝트: pweids/cairo
def test_move_and_data_change_in_time(cleandir):
    root = c.init()
    src = Path() / 'test_dir' / 'test.txt'
    dest = Path() / 'test_dir' / 'empty_dir' / 'test.txt'
    src.rename(dest)

    old_data = dest.read_text()

    time.sleep(.02)
    dest.write_text('change')

    c.commit(root)
    vtime = c.get_versions(root)[-1].time
    before = vtime - timedelta(microseconds=10)
    after = vtime + timedelta(microseconds=10)

    c.ft_at_time(root, before)
    data = src.read_text()
    assert data == old_data

    c.ft_at_time(root, after)
    data = dest.read_text()
    assert data == "change"