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_none_for_distribution(self):
   metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION)
   matcher = MetricResultMatcher(
       namespace=is_not(equal_to('invalidNamespace')),
       name=is_not(equal_to('invalidName')),
       step=is_not(equal_to('invalidStep')),
       labels={
           is_not(equal_to('invalidPcollection')): anything(),
           is_not(equal_to('invalidCustomKey')): is_not(equal_to(
               'invalidCustomValue'))
       },
       committed=is_not(DistributionMatcher(
           sum_value=120,
           count_value=50,
           min_value=100,
           max_value=60
       )),
       attempted=is_not(DistributionMatcher(
           sum_value=120,
           count_value=50,
           min_value=100,
           max_value=60
       )),
   )
   hc_assert_that(metric_result, matcher)
 def test_distribution_does_not_match_counter_and_doesnt_crash(self):
   metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION)
   matcher = is_not(MetricResultMatcher(
       attempted=42,
       committed=42
   ))
   hc_assert_that(metric_result, matcher)
 def test_matches_key_but_not_value(self):
   metric_result = _create_metric_result(EVERYTHING_COUNTER)
   matcher = is_not(MetricResultMatcher(
       labels={
           'pcollection': 'invalidCollection'
       }))
   hc_assert_that(metric_result, matcher)
Exemple #6
0
 def test_update(self):
     entity = self.repository.read(self.default_prefix, "core")
     initial_description = entity.get_data("description")
     entity.data["description"] = "New description"
     entity = self.repository.update(entity)
     assert_that(entity.get_data("description"),
                 is_not(equal_to(initial_description)))
     entity.data["description"] = initial_description
     self.repository.update(entity)
def step(context, handle_color):
    actual_text = context.rate_checker.get_warning_button()
    # If the element's class name includes 'warning'
    # Then the button has turned red
    if(handle_color == 'red'):
        assert_that(actual_text, contains_string("warning"))
    # If the element's class name DOES NOT include 'warning'
    # Then the button has turned green
    elif(handle_color == 'green'):
        assert_that(actual_text, is_not(contains_string("warning")))
Exemple #8
0
def step(context, handle_color):
    actual_text = context.rate_checker.get_warning_button()
    # If the element's class name includes 'warning'
    # Then the button has turned red
    if (handle_color == 'red'):
        assert_that(actual_text, contains_string("warning"))
    # If the element's class name DOES NOT include 'warning'
    # Then the button has turned green
    elif (handle_color == 'green'):
        assert_that(actual_text, is_not(contains_string("warning")))
 def test_matches_none_for_counter(self):
   metric_result = _create_metric_result(EVERYTHING_COUNTER)
   matcher = MetricResultMatcher(
       namespace=is_not(equal_to('invalidNamespace')),
       name=is_not(equal_to('invalidName')),
       step=is_not(equal_to('invalidStep')),
       labels={
           is_not(equal_to('invalidPcollection')): anything(),
           is_not(equal_to('invalidCustomKey')): is_not(equal_to(
               'invalidCustomValue'))
       },
       attempted=is_not(equal_to(1000)),
       committed=is_not(equal_to(1000)))
   hc_assert_that(metric_result, matcher)
 def test_matches_none_for_counter(self):
     metric_result = _create_metric_result(EVERYTHING_COUNTER)
     matcher = MetricResultMatcher(
         namespace=is_not(equal_to('invalidNamespace')),
         name=is_not(equal_to('invalidName')),
         step=is_not(equal_to('invalidStep')),
         labels={
             is_not(equal_to('invalidPcollection')):
             anything(),
             is_not(equal_to('invalidCustomKey')):
             is_not(equal_to('invalidCustomValue'))
         },
         attempted=is_not(equal_to(1000)),
         committed=is_not(equal_to(1000)))
     hc_assert_that(metric_result, matcher)
 def test_counter_does_not_match_distribution_and_doesnt_crash(self):
     metric_result = _create_metric_result(EVERYTHING_COUNTER)
     matcher = is_not(
         MetricResultMatcher(
             committed=DistributionMatcher(sum_value=120,
                                           count_value=50,
                                           min_value=100,
                                           max_value=60),
             attempted=DistributionMatcher(sum_value=120,
                                           count_value=50,
                                           min_value=100,
                                           max_value=60),
         ))
     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_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_counter_does_not_match_distribution_and_doesnt_crash(self):
   metric_result = _create_metric_result(EVERYTHING_COUNTER)
   matcher = is_not(MetricResultMatcher(
       committed=DistributionMatcher(
           sum_value=120,
           count_value=50,
           min_value=100,
           max_value=60
       ),
       attempted=DistributionMatcher(
           sum_value=120,
           count_value=50,
           min_value=100,
           max_value=60
       ),
   ))
   hc_assert_that(metric_result, matcher)
 def test_matches_none_for_distribution(self):
     metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION)
     matcher = MetricResultMatcher(
         namespace=is_not(equal_to('invalidNamespace')),
         name=is_not(equal_to('invalidName')),
         step=is_not(equal_to('invalidStep')),
         labels={
             is_not(equal_to('invalidPcollection')):
             anything(),
             is_not(equal_to('invalidCustomKey')):
             is_not(equal_to('invalidCustomValue'))
         },
         committed=is_not(
             DistributionMatcher(sum_value=120,
                                 count_value=50,
                                 min_value=100,
                                 max_value=60)),
         attempted=is_not(
             DistributionMatcher(sum_value=120,
                                 count_value=50,
                                 min_value=100,
                                 max_value=60)),
     )
     hc_assert_that(metric_result, matcher)
Exemple #16
0
 def testHasAReadableDescription(self):
     self.assert_description("not 'A'", is_not("A"))
Exemple #17
0
 def testDescribeMismatch(self):
     self.assert_describe_mismatch("but was 'A'", is_not("A"), "A")
Exemple #18
0
 def testMismatchDescriptionShowsActualArgument(self):
     self.assert_mismatch_description("but was 'A'", is_not("A"), "A")
Exemple #19
0
 def testProvidesConvenientShortcutForNotEqualTo(self):
     self.assert_matches("invert mismatch", is_not("A"), "B")
     self.assert_does_not_match("invert match", is_not("A"), "A")
Exemple #20
0
 def testEvaluatesToTheTheLogicalNegationOfAnotherMatcher(self):
     self.assert_matches("invert mismatch", is_not(equal_to("A")), "B")
     self.assert_does_not_match("invert match", is_not(equal_to("A")), "A")
Exemple #21
0
 def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
     self.assert_no_mismatch_description(is_not("A"), "B")
 def test_distribution_does_not_match_counter_and_doesnt_crash(self):
     metric_result = _create_metric_result(EVERYTHING_DISTRIBUTION)
     matcher = is_not(MetricResultMatcher(attempted=42, committed=42))
     hc_assert_that(metric_result, matcher)
Exemple #23
0
 def testProvidesConvenientShortcutForNotInstanceOf(self):
     self.assert_matches("invert mismatch", is_not(str), 1)
     self.assert_does_not_match("invert match", is_not(str), "A")
 def test_matches_key_but_not_value(self):
     metric_result = _create_metric_result(EVERYTHING_COUNTER)
     matcher = is_not(
         MetricResultMatcher(labels={'pcollection': 'invalidCollection'}))
     hc_assert_that(metric_result, matcher)
Exemple #25
0
 def test_dont_return_twice_the_same_number(self):
     for x in range(500):
         assert_that(self.next_cell_calculator.next(), is_not(equal_to(self.next_cell_calculator.next())))