Repository: getmoto/moto
Pull request #6269 (2023-04-28 23:44:48)

Scheduler: Fix update_schedule raising ResourceNotFound errors when using schedule groups
The `scheduler:UpdateSchedule` method is broken when using schedule groups since it cannot find the targeted schedule:

```
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the UpdateSchedule operation: Schedule not found
```

The issue is that the retrieved parameter is `groupName` whereas the right parameter for the UpdateSchedule seems to be `GroupName`.

Also, added a new test for this use case.

codecov[bot]: ## [Codecov](https://codecov.io/gh/getmoto/moto/pull/6269?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#6269](https://codecov.io/gh/getmoto/moto/pull/6269?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (fbfe63d) into [master](https://codecov.io/gh/getmoto/moto/commit/e2d35824712e601dde86c023fbaa49d080e50d45?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (e2d3582) will **not change** coverage.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##           master    #6269   +/-   ##
=======================================
  Coverage   96.32%   96.32%           
=======================================
  Files         787      787           
  Lines       76656    76656           
=======================================
  Hits        73836    73836           
  Misses       2820     2820           
```

| Flag | Coverage Δ | |
|---|---|---|
| servertests | `36.97% <0.00%> (ø)` | |
| unittests | `96.26% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/getmoto/moto/pull/6269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [moto/scheduler/responses.py](https://codecov.io/gh/getmoto/moto/pull/6269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-bW90by9zY2hlZHVsZXIvcmVzcG9uc2VzLnB5) | `100.00% <100.00%> (ø)` | |



Patch:
diff --git a/moto/scheduler/responses.py b/moto/scheduler/responses.py
index 9517840e6..ae0e9ef89 100644
--- a/moto/scheduler/responses.py
+++ b/moto/scheduler/responses.py
@@ -60,7 +60,7 @@ class EventBridgeSchedulerResponse(BaseResponse):
         return "{}"
 
     def update_schedule(self) -> str:
-        group_name = self._get_param("groupName")
+        group_name = self._get_param("GroupName")
         name = self.uri.split("?")[0].split("/")[-1]
         description = self._get_param("Description")
         end_date = self._get_param("EndDate")


Test patch:
diff --git a/tests/test_scheduler/test_scheduler.py b/tests/test_scheduler/test_scheduler.py
index 5531a3b0f..399187eef 100644
--- a/tests/test_scheduler/test_scheduler.py
+++ b/tests/test_scheduler/test_scheduler.py
@@ -81,11 +81,22 @@ def test_create_get_delete__in_different_group():
     assert err["Code"] == "ResourceNotFoundException"
 
 
+@pytest.mark.parametrize(
+    "extra_kwargs",
+    [
+        ({}),
+        ({"GroupName": "some-group"}),
+    ],
+    ids=["without_group", "with_group"],
+)
 @mock_scheduler
-def test_update_schedule():
+def test_update_schedule(extra_kwargs):
     client = boto3.client("scheduler", region_name="eu-west-1")
 
+    client.create_schedule_group(Name="some-group")
+
     client.create_schedule(
+        **extra_kwargs,
         Name="my-schedule",
         ScheduleExpression="some cron",
         FlexibleTimeWindow={
@@ -99,6 +110,7 @@ def test_update_schedule():
     )
 
     client.update_schedule(
+        **extra_kwargs,
         Name="my-schedule",
         Description="new desc",
         ScheduleExpression="new cron",
@@ -113,7 +125,7 @@ def test_update_schedule():
         },
     )
 
-    schedule = client.get_schedule(Name="my-schedule")
+    schedule = client.get_schedule(**extra_kwargs, Name="my-schedule")
     assert schedule["Description"] == "new desc"
     assert schedule["ScheduleExpression"] == "new cron"
     assert schedule["State"] == "DISABLED"