def deployment_image_predicate(self, image):
     return ov_factory.value_list_contains(
         jp.DICT_MATCHES(
             {
                 "spec": jp.DICT_MATCHES(
                     {
                         "template": jp.DICT_MATCHES(
                             {
                                 "spec": jp.DICT_MATCHES(
                                     {
                                         "containers": jp.LIST_MATCHES(
                                             [
                                                 jp.DICT_MATCHES(
                                                     {"image": jp.STR_EQ(image)}
                                                 )
                                             ]
                                         )
                                     }
                                 )
                             }
                         )
                     }
                 ),
                 "status": jp.DICT_MATCHES({"availableReplicas": jp.NUM_GE(1)}),
             }
         )
     )
Example #2
0
 def deployment_configmap_mounted_predicate(self, configmap_name):
     return ov_factory.value_list_contains(
         jp.DICT_MATCHES({
             'spec':
             jp.DICT_MATCHES({
                 'template':
                 jp.DICT_MATCHES({
                     'spec':
                     jp.DICT_MATCHES({
                         'volumes':
                         jp.LIST_MATCHES([
                             jp.DICT_MATCHES({
                                 'configMap':
                                 jp.DICT_MATCHES({
                                     'name':
                                     jp.STR_SUBSTR(configmap_name)
                                 })
                             })
                         ])
                     })
                 })
             }),
             'status':
             jp.DICT_MATCHES({'availableReplicas': jp.NUM_GE(1)})
         }))
 def deployment_configmap_mounted_predicate(self, configmap_name):
     return ov_factory.value_list_contains(
         jp.DICT_MATCHES(
             {
                 "spec": jp.DICT_MATCHES(
                     {
                         "template": jp.DICT_MATCHES(
                             {
                                 "spec": jp.DICT_MATCHES(
                                     {
                                         "volumes": jp.LIST_MATCHES(
                                             [
                                                 jp.DICT_MATCHES(
                                                     {
                                                         "configMap": jp.DICT_MATCHES(
                                                             {
                                                                 "name": jp.STR_SUBSTR(
                                                                     configmap_name
                                                                 )
                                                             }
                                                         )
                                                     }
                                                 )
                                             ]
                                         )
                                     }
                                 )
                             }
                         )
                     }
                 ),
                 "status": jp.DICT_MATCHES({"availableReplicas": jp.NUM_GE(1)}),
             }
         )
     )
Example #4
0
  def test_c_put_array(self):
    """Example writes an array value then shows many ways to check values."""
    key = self.make_key('MyArrayKey')
    expect_value = [{'a': 1, 'b': 1}, 2, {'a': 3, 'b': 3}]

    operation = http_agent.HttpPostOperation(
        title='Writing Key Value',
        data=json.JSONEncoder().encode(expect_value),
        path='/put/' + key)
    # Examples of different ways to express things
    builder = st.HttpContractBuilder(self.scenario.agent)
    (builder.new_clause_builder('Contains a=1 and contains b=3')
     .get_url_path('/lookup/' + key)
     .contains_path_value('a', 1)
     .contains_path_value('b', 3))
    (builder.new_clause_builder('Contains (a=1 and b=1))')
     .get_url_path('/lookup/' + key)
     .contains_pred_list([jp.PathPredicate('a', jp.NUM_EQ(1)),
                          jp.PathPredicate('b', jp.NUM_EQ(1))]))
    (builder.new_clause_builder('Does not contain (a=1 and b=3)')
     .get_url_path('/lookup/' + key)
     .excludes_pred_list([jp.PathPredicate('a', jp.NUM_EQ(1)),
                          jp.PathPredicate('b', jp.NUM_EQ(3))]))
    (builder.new_clause_builder('Contains List')
     .get_url_path('/lookup/' + key)
     .contains_match([jp.EQUIVALENT(2),
                      jp.DICT_MATCHES({'a': jp.EQUIVALENT(3),
                                       'b': jp.DIFFERENT(1)})]))
    (builder.new_clause_builder("Contains Multiple A's >= 0")
     .get_url_path('/lookup/' + key)
     .contains_path_pred('a', jp.NUM_GE(0), min=2))
    (builder.new_clause_builder("Contains only 1 A >= 2")
     .get_url_path('/lookup/' + key)
     .contains_path_pred('a', jp.NUM_GE(2), min=1, max=1))
    (builder.new_clause_builder("Contains no A >= 10")
     .get_url_path('/lookup/' + key)
     .excludes_path_pred('a', jp.NUM_GE(10)))

    contract = builder.build()

    test = st.OperationContract(operation, contract)
    self.run_test_case(test)
Example #5
0
 def deployment_image_predicate(self, image):
     return ov_factory.value_list_contains(
         jp.DICT_MATCHES({
             'spec':
             jp.DICT_MATCHES({
                 'template':
                 jp.DICT_MATCHES({
                     'spec':
                     jp.DICT_MATCHES({
                         'containers':
                         jp.LIST_MATCHES(
                             [jp.DICT_MATCHES({'image': jp.STR_EQ(image)})])
                     })
                 })
             }),
             'status':
             jp.DICT_MATCHES({'availableReplicas': jp.NUM_GE(1)})
         }))