def start_post_github_summary_task(task_owner: ApiUser, workspace_id: str, channel_name: str): boundary_dt = utc_now_minus(timedelta(days=1)) slack_installation = SlackInstallation.query.filter_by( workspace_id=workspace_id).first() if not slack_installation: raise ValidationError("workspace not found") job = fetch_github_summary_post_to_slack.queue(slack_installation.id, channel_name, boundary_dt) task = PostGitHubSummaryTask( job_id=job.id, name="Post GitHub Summary", description="Daily task to post GitHub Summary", user=task_owner, data={ "workspace_id": workspace_id, "slack_installation_id": slack_installation.id, "channel_name": channel_name, "boundary_dt": boundary_dt.isoformat(), }, ) db.session.add(task) db.session.commit()
def start_post_github_summary_task(task_owner: ApiUser, channel_name: str): boundary_dt = utc_now_minus(timedelta(days=1)) job = fetch_github_summary_post_to_slack.queue(channel_name, boundary_dt) task = PostGitHubSummaryTask( job_id=job.id, name="Post GitHub Summary", description="Daily task to post GitHub Summary", user=task_owner, data={ "channel_name": channel_name, "boundary_dt": boundary_dt.isoformat() }, ) db.session.add(task) db.session.commit()
def test_post_github_summary_task(session): # Arrange channel_name = "test-channel" task = PostGitHubSummaryTask( job_id="abcd", name="task_created_for_test", description="Task created for testing purposes", data={"channel_name": channel_name}, ) # Act session.add(task) session.commit() # Assert assert task.job_id == "abcd" assert task.complete is False assert task.failed is False assert task.data["channel_name"] == channel_name