Exemplo n.º 1
0
  def test_list_deployments_default_insertime(self):
    """Verify behavior when one of the deployments is missing a timestamp."""
    deployments = [
        Deployment("kf-vfoo-00", "2019-04-01T23:59:59+00:00"),
        Deployment("kf-vfoo-01", "2019-04-02T23:59:59+00:00"),
        Deployment("kf-vfoo-02", "2019-04-03T23:59:59+00:00"),
    ]
    list_resp = {
        "deployments": create_mock_list_resp(deployments),
    }
    # Remove insertTime for the method to attach default timestamp.
    list_resp["deployments"][-1].pop("insertTime", None)
    http = HttpMockSequence([
        ({'status': '200'}, self.dm_api),
        ({'status': '200'}, json.dumps(list_resp)),
        ({"status": "200"}, json.dumps(create_mock_resource_resp(deployments[0]))),
        ({"status": "200"}, json.dumps(create_mock_resource_resp(deployments[1]))),
        ({"status": "200"}, json.dumps(create_mock_resource_resp(deployments[2]))),
    ])
    actual = get_kf_testing_cluster.list_deployments(TEST_PROJECT,
                                                     "kf-vfoo-??",
                                                     TEST_LABEL,
                                                     http=http)
    expected = create_expected_list_resp(deployments)

    # Since the last deployment doesn't have an insertTime it will be ignored
    expected = expected[0:2]

    expected.sort(key=lambda entry: entry["insertTime"],
                  reverse=True)
    self.assertListEqual(actual, expected)
Exemplo n.º 2
0
 def test_list_deployments_multi_pages(self):
   deployments = [
       Deployment("kf-vfoo-n00", "2019-04-01T23:59:59+00:00"),
       Deployment("kf-vfoo-n01", "2019-04-02T23:59:59+00:00"),
       Deployment("kf-vfoo-n02", "2019-04-03T23:59:59+00:00"),
   ]
   list_resp1 = {
       "deployments": create_mock_list_resp(deployments[:1]),
       "nextPageToken": "bar",
   }
   list_resp2 = {
       "deployments": create_mock_list_resp(deployments[1:]),
   }
   http = HttpMockSequence([
       ({'status': '200'}, self.dm_api),
       ({'status': '200'}, json.dumps(list_resp1)),
       ({"status": "200"}, json.dumps(create_mock_resource_resp(deployments[0]))),
       ({"status": "200"}, json.dumps(list_resp2)),
       ({"status": "200"}, json.dumps(create_mock_resource_resp(deployments[1]))),
       ({"status": "200"}, json.dumps(create_mock_resource_resp(deployments[2]))),
   ])
   actual = get_kf_testing_cluster.list_deployments(TEST_PROJECT,
                                                    "kf-vfoo",
                                                    TEST_LABEL,
                                                    http=http)
   expected = sorted(create_expected_list_resp(deployments),
                     key=lambda entry: entry["insertTime"],
                     reverse=True)
   self.assertListEqual(actual, expected)
Exemplo n.º 3
0
 def test_list_deployments_default_insertime(self):
     deployments = [
         Deployment("kf-vfoo-n00", "2019-04-01T23:59:59+00:00"),
         Deployment("kf-vfoo-n01", "2019-04-02T23:59:59+00:00"),
         Deployment("kf-vfoo-n02", "2019-04-03T23:59:59+00:00"),
     ]
     list_resp = {
         "deployments": create_mock_list_resp(deployments),
     }
     # Remove insertTime for the method to attach default timestamp.
     list_resp["deployments"][-1].pop("insertTime", None)
     http = HttpMockSequence([
         ({
             'status': '200'
         }, self.dm_api),
         ({
             'status': '200'
         }, json.dumps(list_resp)),
         ({
             "status": "200"
         }, json.dumps(create_mock_resource_resp(deployments[0]))),
         ({
             "status": "200"
         }, json.dumps(create_mock_resource_resp(deployments[1]))),
         ({
             "status": "200"
         }, json.dumps(create_mock_resource_resp(deployments[2]))),
     ])
     actual = get_kf_testing_cluster.list_deployments(TEST_PROJECT,
                                                      "kf-vfoo",
                                                      TEST_LABEL,
                                                      http=http)
     expected = create_expected_list_resp(deployments)
     expected[-1]["insertTime"] = "1969-12-31T23:59:59+00:00"
     expected.sort(key=lambda entry: entry["insertTime"], reverse=True)
     self.assertListEqual(actual, expected)