def test_compose_p2o_params(self): """Test whether p2o params are built correctly for a backend and a repository""" config = Config(CONF_FILE) task = Task(config) params = task._compose_p2o_params(BACKEND_NAME, REPO_NAME) self.assertEqual(params, {'url': REPO_NAME})
def test_get_collection_url(self): """Test whether the collection url could be overried in a backend""" config = Config(CONF_FILE) task = Task(config) task.backend_section = BACKEND_NAME self.assertEqual(task.conf['es_collection']['url'], COLLECTION_URL) self.assertEqual(task._get_collection_url(), COLLECTION_URL_STACKEXCHANGE)
def test_compose_p2o_params(self): """Test whether p2o params are built correctly for a backend and a repository""" config = Config(CONF_FILE) task = Task(config) params = task._compose_p2o_params( "stackexchange", "https://stackoverflow.com/questions/tagged/example") self.assertEqual( params, {'url': "https://stackoverflow.com/questions/tagged/example"})
def test_initialization(self): """Test whether attributes are initializated""" config = Config(CONF_FILE) task = Task(config) self.assertEqual(task.config, config) self.assertEqual(task.db_sh, task.conf['sortinghat']['database']) self.assertEqual(task.db_user, task.conf['sortinghat']['user']) self.assertEqual(task.db_password, task.conf['sortinghat']['password']) self.assertEqual(task.db_host, task.conf['sortinghat']['host'])
def test_compose_perceval_params(self): """Test whether perceval params are built correctly for a backend and a repository""" config = Config(CONF_FILE) task = Task(config) params = [ '--site', 'stackoverflow.com', '--tagged', 'ovirt', '--tag', 'https://stackoverflow.com/questions/tagged/ovirt', '--api-token', 'token', '--fetch-cache' ] perceval_params = task._compose_perceval_params( BACKEND_NAME, REPO_NAME) self.assertEqual(params.sort(), perceval_params.sort())
def test_compose_perceval_params(self): """Test whether perceval params are built correctly for a backend and a repository""" expected_repo_params = json.loads( read_file('data/task-params-expected')) config = Config(CONF_FILE) task = Task(config) for backend in expected_repo_params.keys(): repo = expected_repo_params.get(backend)['repo'] perceval_params = task._compose_perceval_params(backend, repo) expected_params = expected_repo_params.get(backend)['params'] self.assertEqual(expected_params.sort(), perceval_params.sort())
def test_run(self): """Test whether the Task could be run""" config = Config(CONF_FILE) task = Task(config) self.assertEqual(task.execute(), None)