def test_mget_all(self): '''Can get a list of all projects in ordered by create date ''' project.create_or_get("foo") project.create_or_get("bar") actual = project.mget_all(offset=0, limit=10) eq_(len(actual), 3) eq_([p['project_name'] for p in actual], [self.project_name, 'foo', 'bar'])
def setup_class(cls): '''Load data and record expected results ''' with gus.config.get_db_conn().cursor() as c: c.execute("TRUNCATE TABLE projects CASCADE") cls.expected_id_list = [] cls.expected_id_list.append(project.create_or_get('foo')) cls.expected_id_list.append(project.create_or_get('bar')) cls.expected_id_list.append(project.create_or_get('baz')) cls.expected_object_list = [project.get_by_id(pid) for pid in cls.expected_id_list]
def setup(self): '''Clear out the database & create a test project ''' # TODO: refactor database cleanup self.db_conn = gus.config.get_db_conn() with self.db_conn.cursor() as c: c.execute("TRUNCATE TABLE projects CASCADE") self.project_name = "frobnitz" self.project_id = project.create_or_get(self.project_name)
def build(project_name, branch_name, revision_id, code_path, venv_path): """Register a release candidate with the gus system. Jenkins should call this after a successful build """ from gus.models import project from gus.models import release_candidate project_id = project.create_or_get(project_name) release_candidate.create(project_id, branch_name, revision_id, code_path, venv_path)
def setup_class(cls): """Load test data """ with gus.config.get_db_conn().cursor() as c: c.execute("TRUNCATE TABLE chef_roles, chef_roles_xref_projects CASCADE") project_id = project.create_or_get("outland") cls.expected_id_list = [] cls.expected_id_list.append(chef_role.create('www')) cls.expected_id_list.append(chef_role.create('admin')) cls.expected_id_list.append(chef_role.create('postgres')) chef_role.create('helios') for role_id in cls.expected_id_list: chef_role.add_role_to_project(role_id, project_id) cls.expected_id_list.reverse() cls.expected_object_list = [chef_role.get_by_id(r_id) for r_id in cls.expected_id_list] cls.args = [project_id]
def test_duplicate_create(self): """Trying to create an existing project just returns the existing project """ new_id = project.create_or_get(self.project_name) eq_(new_id, self.project_id)