Exemplo n.º 1
0
    def test_get_deployment(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),
        }
        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]))),
            ({
                '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]))),
        ])

        # get latest deployment.
        self.assertEqual(
            get_kf_testing_cluster.get_deployment(TEST_PROJECT,
                                                  "kf-vfoo",
                                                  TEST_LABEL,
                                                  http=http),
            get_kf_testing_cluster.get_deployment_endpoint(
                TEST_PROJECT, "kf-vfoo-n02"))
        # get oldest deployment.
        self.assertEqual(
            get_kf_testing_cluster.get_deployment(TEST_PROJECT,
                                                  "kf-vfoo",
                                                  TEST_LABEL,
                                                  http=http,
                                                  desc_ordered=False),
            get_kf_testing_cluster.get_deployment_endpoint(
                TEST_PROJECT, "kf-vfoo-n00"))
 def test_get_latest(self):
     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),
     }
     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]))),
     ])
     self.assertEqual(
         get_kf_testing_cluster.get_latest(project=TEST_PROJECT,
                                           base_name="kf-vfoo-??",
                                           http=http),
         get_kf_testing_cluster.get_deployment_endpoint(
             TEST_PROJECT, "kf-vfoo-02"))
Exemplo n.º 3
0
def create_expected_list_resp(deployments):
  """Helper method to create expected responses from get_kf_testing_cluster.list_deployments"""
  data = []
  for d in deployments:
    data.append({
        "name": d.name,
        "endpoint": get_kf_testing_cluster.get_deployment_endpoint(TEST_PROJECT, d.name),
        "insertTime": d.insert_time,
        "zone": d.zone,
    })
  return data