def test_processname(): p = base.ProcessName("test", "upstream", "1", "0") assert str(p) == "test/upstream/1/0" assert p.obj_type == "test" assert p.subtype == "upstream" assert p.obj_id == "1" assert p.seq_id == 0
def test_processname_idx_type(git_gecko, local_gecko_commit): process_name = base.ProcessName("sync", "upstream", "1234", "0") idx = base.ProcessNameIndex(git_gecko) idx.build() idx.insert(process_name) assert idx.get("sync", "upstream", "1234") == {process_name} assert idx.get("sync", "upstream", 1234) == {process_name}
def test_processname_seq_id(git_gecko, local_gecko_commit): process_name_no_seq_id = base.ProcessName("sync", "upstream", "1234", "0") with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, process_name_no_seq_id, {"test": 1}) process_name_seq_id = base.ProcessName.with_seq_id(git_gecko, "sync", "upstream", "1234") assert process_name_seq_id.seq_id == 1
def test_process_name(git_gecko, local_gecko_commit): commit = local_gecko_commit(test_changes={"README": "Example change"}) process_name_no_seq_id = base.ProcessName("sync", "upstream", "open", "1234") base.DataRefObject.create(git_gecko, process_name_no_seq_id, commit) process_name_seq_id = base.ProcessName.with_seq_id(git_gecko, "syncs", "sync", "upstream", "open", "1234") assert process_name_seq_id.seq_id == 1
def test_ref_duplicate(git_gecko): def create_initial(): p = base.ProcessName("sync", "upstream", "1", "0") with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, p, {"test": 1}) create_initial() # Ensure that the p object has been gc'd gc.collect() q = base.ProcessName("sync", "upstream", "1", "0") with pytest.raises(ValueError): with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, q, {"test": 2})
def test_ref_duplicate(git_gecko): commit = git_gecko.commit("FETCH_HEAD") def create_initial(): p = base.ProcessName("test", "subtype", "open", "1") base.DataRefObject.create(git_gecko, p, commit) create_initial() # Ensure that the p object has been gc'd gc.collect() q = base.ProcessName("test", "subtype", "closed", "1") assert q._refs == set() with pytest.raises(ValueError): base.DataRefObject.create(git_gecko, q, commit)
def test_create_delete(env, git_gecko, hg_gecko_upstream): git_gecko.remotes.mozilla.fetch() process_name = base.ProcessName("sync", "downstream", "1", "0") wt = worktree.Worktree(git_gecko, process_name) with SyncLock.for_process(process_name) as lock: base.BranchRefObject.create(lock, git_gecko, process_name, "FETCH_HEAD") with wt.as_mut(lock): wt.get() assert os.path.exists(wt.path) # This is a gecko repo so it ought to have created a state directory state_path = repos.Gecko.get_state_path(env.config, wt.path) assert os.path.exists(state_path) wt.delete() assert not os.path.exists(wt.path) assert not os.path.exists(state_path)
def test_processname_update(git_gecko): commit = git_gecko.commit("FETCH_HEAD") p = base.ProcessName("test", "subtype", "open", "1") assert str(p) == "test/subtype/open/1" assert p.name_filter() == "test/subtype/*/1" assert p.obj_type == "test" assert p.subtype == "subtype" assert p.status == "open" assert p.obj_id == "1" ref = base.DataRefObject.create(git_gecko, p, commit) assert p._refs == set([ref]) assert ref.path == "refs/syncs/test/subtype/open/1" assert ref.ref is not None assert ref.commit.sha1 == commit.hexsha p.status = "complete" assert str(p) == "test/subtype/complete/1" assert ref.path == "refs/syncs/test/subtype/complete/1" assert p._refs == set([ref])
def create_initial(): p = base.ProcessName("sync", "upstream", "1", "0") with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, p, {"test": 1})
def create_initial(): p = base.ProcessName("test", "subtype", "open", "1") base.DataRefObject.create(git_gecko, p, commit)