def setUp(self): # XXX split this out into the setup decorator? self.testdir = tempfile.mkdtemp() self.repodir = join(self.testdir, "repodir") Sandbox.create(self.repodir, True) self.revs = [] sandbox = Sandbox(self.repodir, ctx="tip") self.path = dirname(__file__) self.filelist = ["file1", "file2", "file3"] self.nested_name = "nested/deep/dir/file" self.nested_file = "This is\n\na deeply nested file\n" self.files = [open(join(self.path, i)).read() for i in self.filelist] self.msg = "added some files" self.user = "******" self.date = str(datetime.date.today()) sandbox.add_file_content("file1", self.files[0]) sandbox.add_file_content("file2", self.files[0]) sandbox.commit("added1", "user1 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) sandbox.add_file_content("file1", self.files[1]) sandbox.commit("added2", "user2 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) sandbox.add_file_content("file2", self.files[1]) sandbox.add_file_content("file3", self.files[0]) sandbox.commit("added3", "user3 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) sandbox.add_file_content(self.nested_name, self.nested_file) sandbox.commit("added4", "user3 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) self.fulllist = self.filelist + [self.nested_name] self.repo = Storage(self.repodir, ctx="tip") self.rev = self.repo.rev clearZCML() xmlconfig(open(join(pmr2.mercurial.__path__[0], "utility.zcml"))) # register custom utility that would have normally been done. sm = getSiteManager() sm.registerUtility(MercurialSettings(), IPMR2GlobalSettings) self.settings = zope.component.getUtility(IPMR2GlobalSettings) self.workspace = DummyWorkspace(self.repodir) util.extract_archive(self.testdir) self.pmr2hgtest = DummyWorkspace(join(self.testdir, "pmr2hgtest")) self.import1 = DummyWorkspace(join(self.testdir, "import1")) self.import2 = DummyWorkspace(join(self.testdir, "import2")) self.simple1 = DummyWorkspace(join(self.testdir, "simple1")) self.simple2 = DummyWorkspace(join(self.testdir, "simple2")) self.simple3 = DummyWorkspace(join(self.testdir, "simple3"))
def tearDown(self): tearDown(self) clearZCML() schema.metadata.drop_all(checkfirst=True) session.Session().expunge_all()
def setUp(self): clearZCML() import plone.resource XMLConfig("meta.zcml", plone.resource)()
def tearDown(self): shutil.rmtree(self.testdir) clearZCML()
def setUp(self): clearZCML() import plone.resource XMLConfig('meta.zcml', plone.resource)()
def setUp(self): # XXX split this out into the setup decorator? self.testdir = tempfile.mkdtemp() self.repodir = join(self.testdir, 'repodir') self.revs = [] self.path = dirname(__file__) self.filelist = ['file1', 'file2', 'file3', 'image.png'] self.nested_name = 'nested/deep/dir/file' self.nested_file = 'This is\n\na deeply nested file\n' self.files = [open(join(self.path, i)).read() for i in self.filelist] self.msg = 'added some files' self.user = '******' self.email = '<*****@*****.**>' # Note: to maintain consistency with mercurial (and possibly # other repo formats), nest the bare repo under `.git`. repo = init_repository(join(self.repodir, '.git'), bare=True) tbder = repo.TreeBuilder() tbder.insert('file1', repo.create_blob(self.files[0]), GIT_FILEMODE_BLOB) tbder.insert('file2', repo.create_blob(self.files[0]), GIT_FILEMODE_BLOB) commit = repo.create_commit('refs/heads/master', Signature('user1', '*****@*****.**', int(time()), 0), Signature('user1', '*****@*****.**', int(time()), 0), 'added1', tbder.write(), [], ) self.revs.append(commit.hex) tbder.insert('file1', repo.create_blob(self.files[1]), GIT_FILEMODE_BLOB) commit = repo.create_commit('refs/heads/master', Signature('user2', '*****@*****.**', int(time()), 0), Signature('user2', '*****@*****.**', int(time()), 0), 'added2', tbder.write(), [self.revs[-1]], ) self.revs.append(commit.hex) tbder.insert('file2', repo.create_blob(self.files[1]), GIT_FILEMODE_BLOB) tbder.insert('file3', repo.create_blob(self.files[0]), GIT_FILEMODE_BLOB) tbder.insert('image.png', repo.create_blob(self.files[3]), GIT_FILEMODE_BLOB) commit = repo.create_commit('refs/heads/master', Signature('user3', '*****@*****.**', int(time()), 0), Signature('user3', '*****@*****.**', int(time()), 0), 'added3', tbder.write(), [self.revs[-1]], ) self.revs.append(commit.hex) ntbder = repo.TreeBuilder() nnames = self.nested_name.split('/') ntbder.insert(nnames.pop(), repo.create_blob(self.nested_file), GIT_FILEMODE_BLOB) for n in reversed(nnames): ntree = ntbder.write() ntbder = repo.TreeBuilder() ntbder.insert(n, ntree, GIT_FILEMODE_TREE) # ntree is the final node, n is leftover from the iterator, # ntbder is extra and is ignored. tbder.insert(n, ntree, GIT_FILEMODE_TREE) commit = repo.create_commit('refs/heads/master', Signature('user3', '*****@*****.**', int(time()), 0), Signature('user3', '*****@*****.**', int(time()), 0), 'added4', tbder.write(), [self.revs[-1]], ) self.revs.append(commit.hex) self.fulllist = self.filelist + [self.nested_name] self.rev = commit.hex clearZCML() xmlconfig(open(join(pmr2.git.__path__[0], 'utility.zcml'))) # register custom utility that would have normally been done. sm = getSiteManager() sm.registerUtility(GitSettings(), IPMR2GlobalSettings) self.settings = zope.component.getUtility(IPMR2GlobalSettings) self.workspace = DummyWorkspace(self.repodir) util.extract_archive(self.testdir) self.repodata = DummyWorkspace(join(self.testdir, 'repodata')) self.import1 = DummyWorkspace(join(self.testdir, 'import1')) self.import2 = DummyWorkspace(join(self.testdir, 'import2')) self.simple1 = DummyWorkspace(join(self.testdir, 'simple1')) self.simple2 = DummyWorkspace(join(self.testdir, 'simple2')) self.simple3 = DummyWorkspace(join(self.testdir, 'simple3'))