def test_init(self): path = "/test/path" rep = app.init_repo(path) self.assertEqual(rep.connector.url.path, path) self.assertEqual(rep.index, index.PictureIndex()) self.assertEqual(rep.config, repo.new_repo_config())
def setUp(self): self.connector = MockConnector(urlparse.urlparse('/baseurl/repo/')) self.connector.connect() self.pi = index.PictureIndex() self.pi.add(MockPicture.create_many(10)) self.conf = repo.new_repo_config() self.conf['index.file'] = 'mock-index-path'
def init_repo(url): """ Initialize a new repository and return it. Arguments: url -- URL of the repository to be initialized (e.g. '/home/user/repo'). Returns: The initialized repository. """ config = repo.new_repo_config() connector = Connector.from_string(url) with connector.connected(): rep = repo.Repo.create_on_disk(connector, config) init_repo_logging(rep) log.info("Initialized empty PictureClerk repository") return rep
def new_mock_repo(path, num_pics=0): """ Return a repository containing MockPictures using MockConnector backend. Arguments: num_pics -- Add that many MockPictures to the repository index (default: 0). Returns: Repository instance. """ connector = MockConnector.from_string(path) with connector.connected(): # test index pi = PictureIndex() pi.add(MockPicture.create_many(num_pics)) # test config conf = repo.new_repo_config() conf['index.file'] = ".pic/testindex" conf['test.test'] = "foo" return repo.Repo.create_on_disk(connector, conf, pi)