def test_list_projects(self): write_test_data() session = connection.get_session() project_api = ProjectApi(session) projects = project_api.list_projects() assert len(projects) == 4 assert projects[0].get("id") == "1"
def test_update_project(self): write_test_data() session = connection.get_session() project_api = ProjectApi(session) project = {"extra": '{"test": "test_project2_update_project"}', "main": "test"} project_api.update_project(project_id="1", project=project) ref = project_api.get_project(project_id="1") assert ref.get("extra").get("main") == "test"
def test_update_project_conflict(self): write_test_data() session = connection.get_session() project_api = ProjectApi(session) project = {"name": "test_project2"} try: project_api.update_project(project_id="1", project=project) except Exception as e: assert isinstance(e, exception.Conflict)
def test_create_project(self): write_domain_data() session = connection.get_session() project_api = ProjectApi(session) projects = get_project_data() for project in projects: project = project.to_dict() project_api.create_project(project) refs = project_api.list_projects() assert len(refs) == 4 assert refs[0].get("id") == "1"
def test_create_project_conflict(self): write_domain_data() session = connection.get_session() project_api = ProjectApi(session) projects = get_project_data() for project in projects: project = project.to_dict() project_api.create_project(project) try: project_api.create_project(projects[0].to_dict()) except Exception as e: assert isinstance(e, exception.Conflict)
def test_delete_project(self): write_domain_data() write_project_data() session = connection.get_session() project_api = ProjectApi(session) projects = project_api.list_projects() assert len(projects) == 4 for i in get_project_data(): project_api.delete_project(i.to_dict().get("id")) projects = project_api.list_projects() assert len(projects) == 0 write_project_data() write_user_data() try: project_api.delete_project(project_id="1") except exception.Constraint as e: assert isinstance(e, exception.Constraint) else: pass # raise Exception("Constraint didn't happen") user_api = UserApi(session) users = user_api.list_users()
def test_list_users_for_project(self): write_test_data() session = connection.get_session() project_api = ProjectApi(session) users = project_api.list_users_for_project(project_id="1") assert len(users) == 2
def test_get_project(self): write_test_data() session = connection.get_session() project_api = ProjectApi(session) project = project_api.get_project("1") assert project.get("name") == "test_project1"