@mock.patch('changes.lib.snapshot_garbage_collection.get_current_datetime')
    def test_multiproject(self, get_current_datetime):
        """
        Test the scenario when the cluster that updated also runs another project,
        which has existing cached snapshot images of that cluster.
        """
        project1 = self.create_project()
        project2 = self.create_project()
        plan1_1 = self.create_plan(project1)
        plan1_2 = self.create_plan(project1)
        plan1_3 = self.create_plan(project1)
        plan2_1 = self.create_plan(project2)
        plan2_2 = self.create_plan(project2)

        self.create_step(plan1_1, data={'cluster': 'cluster1'})
        self.create_step(plan1_2, data={'cluster': 'cluster2'})
        self.create_step(plan2_1, data={'cluster': 'cluster2'})
        self.create_step(plan2_2, data={'cluster': 'cluster3'})

        snapshot1 = self.create_snapshot(project1)
        snapshot2 = self.create_snapshot(project2)
        snapshot_image1_1 = self.create_snapshot_image(snapshot1, plan1_1)
        snapshot_image1_2 = self.create_snapshot_image(snapshot1, plan1_2)
        snapshot_image1_3 = self.create_snapshot_image(snapshot1, plan1_3)
        snapshot_image2_1 = self.create_snapshot_image(snapshot2, plan2_1)
        snapshot_image2_2 = self.create_snapshot_image(snapshot2, plan2_2)

        self.create_cached_snapshot_image(snapshot_image2_1)
        self.create_cached_snapshot_image(snapshot_image2_2)

        get_current_datetime.return_value = self.mock_datetime

        resp = self.client.post(self.get_endpoint_path(snapshot1.id))
        assert resp.status_code == 200
        data = self.unserialize(resp)

        assert len(data) == 2
        assert 'cluster1' in data
        assert 'cluster2' in data
        assert len(data['cluster1']) == 1
        assert snapshot_image1_1.id.hex in data['cluster1']
        assert len(data['cluster2']) == 2
        assert snapshot_image1_2.id.hex in data['cluster2']
        assert snapshot_image2_1.id.hex in data['cluster2']
dataset/ETHPy150Open dropbox/changes/tests/changes/api/test_cached_snapshot_details.py/CachedSnapshotClusterDetailsAPITestCase.test_multiproject/original