  def testDeploymentReplicaSet(self, mock_list_replica_set):
    """Test that a ReplicaSet matching the Deployment's spec is returned."""
    mock_list_replica_set.return_value.items = [
        k8s_mocks.V1ReplicaSet(name='replicaset-0', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(name='replicaset-1', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(name='replicaset-2', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(name='replicaset-3', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(
            name='replicaset-4',
            template_spec_labels={
                'app': 'nginx', 'pod-template-hash': 'abcd'
            }),
        k8s_mocks.V1ReplicaSet(name='replicaset-5', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(name='replicaset-6', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(name='replicaset-7', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(name='replicaset-8', template_spec_labels={}),
        k8s_mocks.V1ReplicaSet(name='replicaset-9', template_spec_labels={}),
    ]

    deployment = workloads.K8sDeployment(
        k8s_mocks.MOCK_API_CLIENT, 'deployment', 'default')
    with mock.patch.object(deployment, 'Read') as mock_read:
      mock_read.return_value = k8s_mocks.V1Deployment(
          template_spec_labels={'app': 'nginx'},
          # Match labels are not important here since API return value is
          # predefined
          match_labels={})
      self.assertEqual('replicaset-4', deployment._ReplicaSet().name)  # pylint: disable=protected-access
Test that a ReplicaSet matching the Deployment's spec is returned.
tests/providers/kubernetes/test_workloads.py