示例#1
0
    def test_get_mail_templates(self):
        templates = self.__mail_service.get_mail_templates()
        assert_that(templates, has_length(greater_than(0)))

        templates = \
            self.__mail_service.get_mail_templates(
                types=frozenset((MailTemplateType(TemplateType.BASE),))
            )
        assert_that(templates, has_length(greater_than(0)))
示例#2
0
    def test_get_mail_templates(self):
        templates = self.__mail_service.get_mail_templates()
        assert_that(templates, has_length(greater_than(0)))

        templates = \
            self.__mail_service.get_mail_templates(
                types=frozenset((MailTemplateType(TemplateType.BASE),))
            )
        assert_that(templates, has_length(greater_than(0)))
    def test_list_and_resolve_all(self):
        search = self.repository.list()
        self._assert_valid_search_list_result(search)
        assert_that(len(search.results), greater_than(0))

        result = self.repository.resolve_all(search)
        assert_that(result, not_none())
        assert_that(result, instance_of(list))
        assert_that(len(result), greater_than(0))
        self._assert_valid_default_entity(result[0], result[0].id)
 def test_matches_distribution_with_custom_matchers(self):
   metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION)
   matcher = is_not(MetricResultMatcher(
       namespace=equal_to_ignoring_case('MYNAMESPACE'),
       name=equal_to_ignoring_case('MYNAME'),
       step=equal_to_ignoring_case('MYSTEP'),
       labels={
           equal_to_ignoring_case('PCOLLECTION') :
               equal_to_ignoring_case('MYCUSTOMVALUE'),
           'myCustomKey': equal_to_ignoring_case('MYCUSTOMVALUE')
       },
       committed=is_not(DistributionMatcher(
           sum_value=greater_than(-1),
           count_value=greater_than(-1),
           min_value=greater_than(-1),
           max_value=greater_than(-1)
       )),
       attempted=is_not(DistributionMatcher(
           sum_value=greater_than(-1),
           count_value=greater_than(-1),
           min_value=greater_than(-1),
           max_value=greater_than(-1)
       )),
   ))
   hc_assert_that(metric_result, matcher)
 def test_matches_distribution_with_custom_matchers(self):
     metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION)
     matcher = is_not(
         MetricResultMatcher(
             namespace=equal_to_ignoring_case('MYNAMESPACE'),
             name=equal_to_ignoring_case('MYNAME'),
             step=equal_to_ignoring_case('MYSTEP'),
             labels={
                 equal_to_ignoring_case('PCOLLECTION'):
                 equal_to_ignoring_case('MYCUSTOMVALUE'),
                 'myCustomKey':
                 equal_to_ignoring_case('MYCUSTOMVALUE')
             },
             committed=is_not(
                 DistributionMatcher(sum_value=greater_than(-1),
                                     count_value=greater_than(-1),
                                     min_value=greater_than(-1),
                                     max_value=greater_than(-1))),
             attempted=is_not(
                 DistributionMatcher(sum_value=greater_than(-1),
                                     count_value=greater_than(-1),
                                     min_value=greater_than(-1),
                                     max_value=greater_than(-1))),
         ))
     hc_assert_that(metric_result, matcher)
 def test_matches_counter_with_custom_matchers(self):
   metric_result = _create_metric_result(EVERYTHING_COUNTER)
   matcher = is_not(MetricResultMatcher(
       namespace=equal_to_ignoring_case('MYNAMESPACE'),
       name=equal_to_ignoring_case('MYNAME'),
       step=equal_to_ignoring_case('MYSTEP'),
       labels={
           equal_to_ignoring_case('PCOLLECTION') :
               equal_to_ignoring_case('MYCUSTOMVALUE'),
           'myCustomKey': equal_to_ignoring_case('MYCUSTOMVALUE')
       },
       committed=greater_than(0),
       attempted=greater_than(0)
   ))
   hc_assert_that(metric_result, matcher)
    def test_list_and_resolve_first(self):
        search = self.repository.list()
        self._assert_valid_search_list_result(search)
        assert_that(len(search.results), greater_than(0))

        result = self.repository.resolve(search.results[0])
        self._assert_valid_default_entity(result, result.id)
 def test_matches_counter_with_custom_matchers(self):
     metric_result = _create_metric_result(EVERYTHING_COUNTER)
     matcher = is_not(
         MetricResultMatcher(
             namespace=equal_to_ignoring_case('MYNAMESPACE'),
             name=equal_to_ignoring_case('MYNAME'),
             step=equal_to_ignoring_case('MYSTEP'),
             labels={
                 equal_to_ignoring_case('PCOLLECTION'):
                 equal_to_ignoring_case('MYCUSTOMVALUE'),
                 'myCustomKey':
                 equal_to_ignoring_case('MYCUSTOMVALUE')
             },
             committed=greater_than(0),
             attempted=greater_than(0)))
     hc_assert_that(metric_result, matcher)
示例#9
0
 def _assert_valid_default_entity(result,
                                  identifier="hbp/core/testschema/v0.0.1"):
     assert_that(result, instance_of(Schema))
     assert_that(result.data, not_none())
     assert_that(result.get_revision(), greater_than(0))
     assert_that(result.id, equal_to(identifier))
     assert_that(result.path, equal_to("/schemas/" + identifier))
def legacy_metric_matchers():
  """MetricResult matchers with adjusted step names for the legacy DF test."""
  # TODO(ajamato): Move these to the common_metric_matchers once implemented
  # in the FN API.
  matchers = common_metric_matchers()
  matchers.extend([
      # User distribution metric, legacy DF only.
      MetricResultMatcher(
          name='distribution_values',
          namespace=METRIC_NAMESPACE,
          step='metrics',
          attempted=DistributionMatcher(
              sum_value=sum(INPUT),
              count_value=len(INPUT),
              min_value=min(INPUT),
              max_value=max(INPUT)
          ),
          committed=DistributionMatcher(
              sum_value=sum(INPUT),
              count_value=len(INPUT),
              min_value=min(INPUT),
              max_value=max(INPUT)
          ),
      ),
      # Element count and MeanByteCount for a User ParDo.
      MetricResultMatcher(
          name='ElementCount',
          labels={
              'output_user_name': 'metrics-out0',
              'original_name': 'metrics-out0-ElementCount'
          },
          attempted=greater_than(0),
          committed=greater_than(0)
      ),
      MetricResultMatcher(
          name='MeanByteCount',
          labels={
              'output_user_name': 'metrics-out0',
              'original_name': 'metrics-out0-MeanByteCount'
          },
          attempted=greater_than(0),
          committed=greater_than(0)
      ),
  ])
  return matchers
示例#11
0
def step(context, range_operation):
    # get the range text from below the slider handle
    range_text = context.rate_checker.get_credit_score_range()
    currentRange = int(range_text[:3])

    if (range_operation == "increase"):
        assert_that(currentRange, greater_than(DEFAULT_CREDIT_SCORE))
    elif (range_operation == "decrease"):
        assert_that(currentRange, less_than(DEFAULT_CREDIT_SCORE))
def step(context, range_operation):
    # get the range text from below the slider handle
    range_text = context.rate_checker.get_credit_score_range()
    currentRange = int(range_text[:3])

    if (range_operation == "increase"):
        assert_that(currentRange, greater_than(DEFAULT_CREDIT_SCORE))
    elif (range_operation == "decrease"):
        assert_that(currentRange, less_than(DEFAULT_CREDIT_SCORE))
 def test_search_items(self):
     """ This test assumes specific test data - we therefore do not apply assumptions but make this test rather a manual one until we can ensure a specific testdata set. """
     search = self.client.instances.list(full_text_query="interneuron")
     assert_that(len(search.results), greater_than(0))
     results = self.client.instances.resolve_all(search)
     print results
     for r in results:
         data_url = r.get_data("dataurl")
         if data_url:
             print data_url["downloadURL"]
示例#14
0
    def test_get_products_query(self):
        if self.__catalog_service is None:
            return

        if self.__read_only:
            products = self.__catalog_service.get_products(query='dvd')
            assert_that(products, has_length(greater_than(0)))
        else:
            self.__put_products()
            products = self.__catalog_service.get_products(query='1')
            assert_that(products, has_length(1))
示例#15
0
    def test_get_product_count(self):
        if self.__catalog_service is None:
            return

        if self.__read_only:
            product_count = self.__catalog_service.get_product_count()
            assert_that(product_count, greater_than(0))
        else:
            self.__put_products()

            product_count = self.__catalog_service.get_product_count()
            assert_that(product_count, equal_to(len(self.__products)))
示例#16
0
    def test_head_product_by_sku(self):
        if self.__catalog_service is None:
            return

        if not self.__read_only:
            self.__put_products()

        product_skus = self.__catalog_service.get_product_skus()
        assert_that(product_skus, has_length(greater_than(0)))
        for product_sku in product_skus:
            head = self.__catalog_service.head_product_by_sku(product_sku)
            assert_that(head, instance_of(bool))
            self.assertTrue(head)
        self.assertFalse(self.__catalog_service.head_product_by_sku('nonextantsku'))
示例#17
0
    def test_get_product_skus(self):
        if self.__catalog_service is None:
            return

        if not self.__read_only:
            self.__put_products()

        product_skus = self.__catalog_service.get_product_skus()
        assert_that(product_skus, has_length(greater_than(0)))
        for product_sku in product_skus:
            assert_that(product_sku, instance_of(basestring))

        if not self.__read_only:
            assert_that(product_skus, equal_to(self.__product_skus))
示例#18
0
    def test_get_product_by_sku(self):
        if self.__catalog_service is None:
            return

        if not self.__read_only:
            self.__put_products()

        product_skus = self.__catalog_service.get_product_skus()
        assert_that(product_skus, has_length(greater_than(0)))
        for product_sku in product_skus:
            product = self.__catalog_service.get_product_by_sku(product_sku)
            assert_that(product, instance_of(Product))

        try:
            self.__catalog_service.get_product_by_sku('nonexitantsku')
            self.fail()
        except NoSuchProductException:
            pass
示例#19
0
    def test_get_products_include_disabled(self):
        if self.__catalog_service is None:
            return

        if self.__read_only:
            products = self.__catalog_service.get_products(include_disabled=True)
            assert_that(products, has_length(greater_than(0)))
        else:
            self.__put_products()

            disabled_product = list(self.__products)[0]
            disabled_product = disabled_product.replace(magento_product=disabled_product.magento_product.replace(sku='Test product disabled').replace(status=MagentoProductStatus.DISABLED))
            self.__catalog_service.put_product(disabled_product)

            products = self.__catalog_service.get_products(include_disabled=True)
            assert_that(products, equal_to(frozenset(list(self.__products) + [disabled_product])))

            enabled_products = self.__catalog_service.get_products(include_disabled=False)
            assert_that(enabled_products, equal_to(self.__products))
示例#20
0
 def test_get_mail_lists(self):
     lists = self.__mail_service.get_mail_lists()
     assert_that(lists, has_length(greater_than(0)))
示例#21
0
def step(context):
    context.json_data = json.loads(context.response.text)
    context.logger.debug("timestamp is: %s" % context.json_data['timestamp'])
    assert_that(len(context.json_data[u'timestamp']), greater_than(0))
def common_metric_matchers():
  """MetricResult matchers common to all tests."""
  # TODO(ajamato): Matcher for the 'metrics' step's ElementCount.
  # TODO(ajamato): Matcher for the 'metrics' step's MeanByteCount.
  # TODO(ajamato): Matcher for the start and finish exec times.
  # TODO(ajamato): Matcher for a gauge metric once implemented in dataflow.
  matchers = [
      # User Counter Metrics.
      MetricResultMatcher(
          name='total_values',
          namespace=METRIC_NAMESPACE,
          step='metrics',
          attempted=sum(INPUT),
          committed=sum(INPUT)
      ),
      MetricResultMatcher(
          name='ExecutionTime_StartBundle',
          step='metrics',
          attempted=greater_than(0),
          committed=greater_than(0)
      ),
      MetricResultMatcher(
          name='ExecutionTime_ProcessElement',
          step='metrics',
          attempted=greater_than(0),
          committed=greater_than(0)
      ),
      MetricResultMatcher(
          name='ExecutionTime_FinishBundle',
          step='metrics',
          attempted=greater_than(0),
          committed=greater_than(0)
      )
  ]

  pcoll_names = [
      'GroupByKey/Reify-out0',
      'GroupByKey/Read-out0',
      'map_to_common_key-out0',
      'GroupByKey/GroupByWindow-out0',
      'GroupByKey/Read-out0',
      'GroupByKey/Reify-out0'
  ]
  for name in pcoll_names:
    matchers.extend([
        MetricResultMatcher(
            name='ElementCount',
            labels={
                'output_user_name': name,
                'original_name': '%s-ElementCount' % name
            },
            attempted=greater_than(0),
            committed=greater_than(0)
        ),
        MetricResultMatcher(
            name='MeanByteCount',
            labels={
                'output_user_name': name,
                'original_name': '%s-MeanByteCount' % name
            },
            attempted=greater_than(0),
            committed=greater_than(0)
        ),
    ])
  return matchers
 def test_list_default(self):
     search = self.repository.list()
     self._assert_valid_search_list_result(search)
     assert_that(len(search.results), greater_than(0))
def metric_matchers():
    """MetricResult matchers common to all tests."""
    # TODO(ajamato): Matcher for the 'metrics' step's ElementCount.
    # TODO(ajamato): Matcher for the 'metrics' step's MeanByteCount.
    # TODO(ajamato): Matcher for the start and finish exec times.
    # TODO(ajamato): Matcher for a gauge metric once implemented in dataflow.
    matchers = [
        # User Counter Metrics.
        MetricResultMatcher(name='total_values',
                            namespace=METRIC_NAMESPACE,
                            step='metrics',
                            attempted=sum(INPUT),
                            committed=sum(INPUT)),
        MetricResultMatcher(name='ExecutionTime_StartBundle',
                            step='metrics',
                            attempted=greater_than(0),
                            committed=greater_than(0)),
        MetricResultMatcher(name='ExecutionTime_ProcessElement',
                            step='metrics',
                            attempted=greater_than(0),
                            committed=greater_than(0)),
        MetricResultMatcher(name='ExecutionTime_FinishBundle',
                            step='metrics',
                            attempted=greater_than(0),
                            committed=greater_than(0)),
        MetricResultMatcher(
            name='distribution_values',
            namespace=METRIC_NAMESPACE,
            step='metrics',
            attempted=DistributionMatcher(sum_value=sum(INPUT),
                                          count_value=len(INPUT),
                                          min_value=min(INPUT),
                                          max_value=max(INPUT)),
            committed=DistributionMatcher(sum_value=sum(INPUT),
                                          count_value=len(INPUT),
                                          min_value=min(INPUT),
                                          max_value=max(INPUT)),
        ),
        # Element count and MeanByteCount for a User ParDo.
        MetricResultMatcher(name='ElementCount',
                            labels={
                                'output_user_name': 'metrics-out0',
                                'original_name': 'metrics-out0-ElementCount'
                            },
                            attempted=greater_than(0),
                            committed=greater_than(0)),
        MetricResultMatcher(name='MeanByteCount',
                            labels={
                                'output_user_name': 'metrics-out0',
                                'original_name': 'metrics-out0-MeanByteCount'
                            },
                            attempted=greater_than(0),
                            committed=greater_than(0))
    ]

    pcoll_names = [
        'GroupByKey/Reify-out0', 'GroupByKey/Read-out0',
        'map_to_common_key-out0', 'GroupByKey/GroupByWindow-out0',
        'GroupByKey/Read-out0', 'GroupByKey/Reify-out0'
    ]
    for name in pcoll_names:
        matchers.extend([
            MetricResultMatcher(name='ElementCount',
                                labels={
                                    'output_user_name': name,
                                    'original_name': '%s-ElementCount' % name
                                },
                                attempted=greater_than(0),
                                committed=greater_than(0)),
            MetricResultMatcher(name='MeanByteCount',
                                labels={
                                    'output_user_name': name,
                                    'original_name': '%s-MeanByteCount' % name
                                },
                                attempted=greater_than(0),
                                committed=greater_than(0)),
        ])
    return matchers
 def testMismatchDescription(self):
     self.assert_mismatch_description("was <0>", greater_than(1), 0)
     self.assert_mismatch_description("was <2>", less_than(1), 2)
     self.assert_mismatch_description("was <0>", greater_than_or_equal_to(1), 0)
     self.assert_mismatch_description("was <2>", less_than_or_equal_to(1), 2)
示例#26
0
def step(context):
    context.json_data = json.loads(context.response.text)
    context.logger.debug("JSON data is: %s" % context.json_data['data'])

    assert_that(len(context.json_data[u'data']), greater_than(0))
示例#27
0
 def test_get_mail_lists(self):
     lists = self.__mail_service.get_mail_lists()
     assert_that(lists, has_length(greater_than(0)))
 def testComparesObjectsForGreaterThan(self):
     self.assert_matches("match", greater_than(1), 2)
     self.assert_does_not_match("no match", greater_than(1), 1)
示例#29
0
 def testHasReadableDescription(self):
     self.assert_description('an object with length of a value greater than <5>',
                             has_length(greater_than(5)))
示例#30
0
 def test_get_mail_template_info(self):
     templates = self.__mail_service.get_mail_templates()
     assert_that(templates, has_length(greater_than(0)))
     for template in templates:
         self.__mail_service.get_mail_template_info(
             template.mail_chimp_template.id)
 def testDescribeMismatch(self):
     self.assert_describe_mismatch("was <0>", greater_than(1), 0)
     self.assert_describe_mismatch("was <2>", less_than(1), 2)
     self.assert_describe_mismatch("was <0>", greater_than_or_equal_to(1), 0)
     self.assert_describe_mismatch("was <2>", less_than_or_equal_to(1), 2)
示例#32
0
def step(context):
    context.json_data = json.loads(context.response.text)
    context.logger.debug("timestamp is: %s" % context.json_data['timestamp'])
    assert_that(len(context.json_data[u'timestamp']), greater_than(0))
 def _assert_valid_default_entity(result, identifier):
     assert_that(result, instance_of(Instance))
     assert_that(result.data, not_none())
     assert_that(result.get_revision(), greater_than(0))
     assert_that(result.id, equal_to(identifier))
     assert_that(result.path, equal_to("/data/" + identifier))
示例#34
0
def step(context):
    context.json_data = json.loads(context.response.text)
    context.logger.debug("JSON data is: %s" % context.json_data['data'])

    assert_that(len(context.json_data[u'data']), greater_than(0))
 def test_list_incl_deprecated(self):
     search = self.repository.list(deprecated=None)
     self._assert_valid_search_list_result(search)
     assert_that(len(search.results), greater_than(0))
示例#36
0
 def test_get_mail_template_info(self):
     templates = self.__mail_service.get_mail_templates()
     assert_that(templates, has_length(greater_than(0)))
     for template in templates:
         self.__mail_service.get_mail_template_info(template.mail_chimp_template.id)
 def testSupportsDifferentTypesOfComparableObjects(self):
     self.assert_matches("strings", greater_than("bb"), "cc")
     self.assert_matches("dates", less_than(date.today()), date.min)
 def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
     self.assert_no_mismatch_description(greater_than(1), 2)
     self.assert_no_mismatch_description(less_than(1), 0)
     self.assert_no_mismatch_description(greater_than_or_equal_to(1), 1)
     self.assert_no_mismatch_description(less_than_or_equal_to(1), 1)
 def testHasAReadableDescription(self):
     self.assert_description("a value greater than <1>", greater_than(1))
     self.assert_description("a value greater than or equal to <1>", greater_than_or_equal_to(1))
     self.assert_description("a value less than <1>", less_than(1))
     self.assert_description("a value less than or equal to <1>", less_than_or_equal_to(1))
示例#40
0
def step(context, param_name):
    context.json_data = json.loads(context.response.text)
    context.logger.debug("What's in context json:%s" % context.json_data)
    context.logger.debug("JSON data is: %s" % context.json_data[param_name])

    assert_that(len(context.json_data[param_name]), greater_than(0))