示例#1
0
 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"
示例#2
0
 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"
示例#3
0
    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()