コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #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)
コード例 #7
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")))
コード例 #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")))
コード例 #9
0
 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)
コード例 #10
0
 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)
コード例 #11
0
 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)
コード例 #12
0
 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)
コード例 #13
0
 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)
コード例 #14
0
 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)
コード例 #15
0
 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)
コード例 #16
0
ファイル: isnot_test.py プロジェクト: tiago-peres/PyHamcrest
 def testHasAReadableDescription(self):
     self.assert_description("not 'A'", is_not("A"))
コード例 #17
0
ファイル: isnot_test.py プロジェクト: tiago-peres/PyHamcrest
 def testDescribeMismatch(self):
     self.assert_describe_mismatch("but was 'A'", is_not("A"), "A")
コード例 #18
0
ファイル: isnot_test.py プロジェクト: tiago-peres/PyHamcrest
 def testMismatchDescriptionShowsActualArgument(self):
     self.assert_mismatch_description("but was 'A'", is_not("A"), "A")
コード例 #19
0
ファイル: isnot_test.py プロジェクト: tiago-peres/PyHamcrest
 def testProvidesConvenientShortcutForNotEqualTo(self):
     self.assert_matches("invert mismatch", is_not("A"), "B")
     self.assert_does_not_match("invert match", is_not("A"), "A")
コード例 #20
0
ファイル: isnot_test.py プロジェクト: tiago-peres/PyHamcrest
 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")
コード例 #21
0
ファイル: isnot_test.py プロジェクト: tiago-peres/PyHamcrest
 def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
     self.assert_no_mismatch_description(is_not("A"), "B")
コード例 #22
0
 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)
コード例 #23
0
ファイル: isnot_test.py プロジェクト: tiago-peres/PyHamcrest
 def testProvidesConvenientShortcutForNotInstanceOf(self):
     self.assert_matches("invert mismatch", is_not(str), 1)
     self.assert_does_not_match("invert match", is_not(str), "A")
コード例 #24
0
 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)
コード例 #25
0
ファイル: unit.py プロジェクト: rubenbp/roboexplorer
 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())))