text: import json
  
  from werkzeug.sansio.response import Response
  
  from tests.conftest import DefaultData
  from tests.utils.mock_backend import backend, ctx, Project
  
  
  def test_greetings():
      response: Response = backend.get("/hello")
  
      assert response.status_code == 200
  
  
  def test_get_user(default_data: DefaultData):
      response: Response = backend.get("/api/user", headers={"Authorization": f"manta-apikey {default_data.api_key.key}"})
  
      assert response.status_code == 200
      assert response.json == default_data.user.__dict__
  
  
  def test_get_user_detail(default_data: DefaultData):
      response: Response = backend.get(
          "/api/user/profile", headers={"Authorization": f"manta-apikey {default_data.api_key.key}"}
      )
  
      assert response.status_code == 200
      assert response.json == default_data.user.__dict__
  
  
  def test_create_team(default_data: DefaultData):
      response: Response = backend.post(
          "/api/team",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
          json={"uid": "foo"},
      )
  
      assert response.status_code == 201
      assert response.json["Id"] is not None
  
      team_id = response.json["Id"]
      response: Response = backend.get(
          f"/api/team/{team_id}", headers={"Authorization": f"manta-apikey {default_data.api_key.key}"}
      )
      assert response.status_code == 200
  
  
  def test_get_team(default_data: DefaultData):
      team_id = default_data.team.Id
      response: Response = backend.get(
          f"/api/team/{team_id}", headers={"Authorization": f"manta-apikey {default_data.api_key.key}"}
      )
  
      assert response.status_code == 200
      assert response.json == default_data.team.__dict__
  
  
  def test_get_my_teams(default_data: DefaultData):
      response: Response = backend.get(
          "/api/team/my", headers={"Authorization": f"manta-apikey {default_data.api_key.key}"}
      )
  
      assert response.status_code == 200
      assert response.json == {"teams": [default_data.team.__dict__]}
  
  
  def test_get_personal_team(default_data: DefaultData):
      response: Response = backend.get(
          "/api/team/my/personal", headers={"Authorization": f"manta-apikey {default_data.api_key.key}"}
      )
  
      assert response.status_code == 200
      assert response.json == default_data.team.__dict__
  
  
  def test_project():
      project = Project(**{"teamId": "zoo", "name": "foo", "description": "bar"})
      assert project.teamId == "zoo"
      assert project.name == "foo"
      assert project.description == "bar"
  
  
  def test_create_project(default_data: DefaultData):
      team_id = default_data.team.Id
      response: Response = backend.post(
          f"/api/team/{team_id}/project",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
          json={"name": "foo", "description": "bar"},
      )
      assert response.status_code == 201
      assert response.json is not None
      assert response.json["Id"] is not None
  
      response: Response = backend.get(
          f"/api/project/{response.json['Id']}",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 200
  
  
  def test_get_project_detail(default_data: DefaultData):
      project_id = default_data.project.Id
      response: Response = backend.get(
          f"/api/project/{project_id}",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 200
  
  
  def test_get_my_projects(default_data: DefaultData):
      team_id = default_data.team.Id
      response: Response = backend.get(
          f"/api/team/{team_id}/project/my",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 200
      assert response.json == {"projects": [default_data.project.__dict__]}
  
  
  def test_delete_project(default_data: DefaultData):
      project_id = default_data.project.Id
      response: Response = backend.delete(
          f"/api/project/{project_id}",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 204
  
  
  def test_create_run(default_data: DefaultData):
      project_id = default_data.project.Id
      response: Response = backend.post(
          f"/api/project/{project_id}/run",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
          json={"name": "foo"},
      )
  
      assert response.status_code == 201
  
  
  def test_get_runs_by_project_id(default_data: DefaultData):
      project_id = default_data.project.Id
      response: Response = backend.get(
          f"/api/project/{project_id}/run",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 200
      assert response.json == {"runs": [default_data.run.__dict__]}
  
  
  def test_get_run(default_data: DefaultData):
      run_id = default_data.run.Id
      response: Response = backend.get(
          f"/api/run/{run_id}",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 200
      assert response.json == default_data.run.__dict__
  
  
  def test_delete_run(default_data: DefaultData):
      run_id = default_data.run.Id
      response: Response = backend.delete(
          f"/api/run/{run_id}",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 204
  
  
  def test_add_run_record(default_data: DefaultData):
      run_id = default_data.run.Id
      response: Response = backend.post(
          f"/api/run/{run_id}/record",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
          json={"histories": [{"foo": "foo"}], "systems": [{"bar": "bar"}], "logs": [{"zoo": "zoo"}]},
      )
  
      assert response.status_code == 204
  
      response: Response = backend.get(
          f"/api/run/{run_id}",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
      )
  
      assert response.status_code == 200
      assert response.json["histories"] == [{"foo": "foo"}]
      assert response.json["systems"] == [{"bar": "bar"}]
      assert response.json["logs"] == [{"zoo": "zoo"}]
  
  
  def test_add_run_record_empty(default_data: DefaultData):
      run_id = default_data.run.Id
      response: Response = backend.post(
          f"/api/run/{run_id}/record",
          headers={"Authorization": f"manta-apikey {default_data.api_key.key}"},
          json={},
      )
  
      assert response.status_code == 204
  