From 390ebbfa2d58a89b2c39a6081987a95a02faa34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <pmaslanka@smok.co> Date: Thu, 30 Dec 2021 16:45:16 +0100 Subject: [PATCH] fixed unit tests, migrated to CircleCI --- CHANGELOG.md | 2 ++ README.md | 2 +- tests/test_coding/test_structures.py | 5 +++-- .../test_metrics/test_metrics.py | 14 ++++++++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e5fa48..9e09fb7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,3 @@ # v2.18.11 + +* unit tests migrated to CircleCI diff --git a/README.md b/README.md index 6e7933db..542be0fa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ satella ======== -[](https://app.travis-ci.com/github/piotrmaslanka/satella) +[](https://app.circleci.com/pipelines/github/piotrmaslanka/satella) [](https://codeclimate.com/github/piotrmaslanka/satella/test_coverage) [](https://codeclimate.com/github/piotrmaslanka/satella) [](https://codeclimate.com/github/piotrmaslanka/satella) diff --git a/tests/test_coding/test_structures.py b/tests/test_coding/test_structures.py index 4e6a6fe1..9373b5ec 100644 --- a/tests/test_coding/test_structures.py +++ b/tests/test_coding/test_structures.py @@ -523,8 +523,9 @@ class TestStructures(unittest.TestCase): def __init__(self, v): self.v = v - self.assertTrue(repr(Test2(2)).endswith( - 'test_coding.test_structures.TestMisc.test_reprable_mixin.<locals>.Test2(2)')) + self.assertEqual(repr(Test2(2)), + 'tests.test_coding.test_structures.TestStructures.' \ + 'test_reprable_mixin.<locals>.Test2(2)') def test_proxy(self): a = Proxy(5, wrap_operations=True) diff --git a/tests/test_instrumentation/test_metrics/test_metrics.py b/tests/test_instrumentation/test_metrics/test_metrics.py index df00b539..4efd64f0 100644 --- a/tests/test_instrumentation/test_metrics/test_metrics.py +++ b/tests/test_instrumentation/test_metrics/test_metrics.py @@ -4,6 +4,7 @@ import time import unittest from satella.coding.sequences import n_th +from satella.coding.transforms import is_subset from satella.exceptions import MetricAlreadyExists from satella.instrumentation.metrics import getMetric, MetricLevel, MetricData, \ @@ -13,8 +14,13 @@ logger = logging.getLogger(__name__) def choose(postfix: str, mdc: MetricDataCollection, labels=None) -> MetricData: + labels = labels or {} + print('looking for', postfix, labels) for child in mdc.values: - if child.name.endswith(postfix) and child.labels == (labels or {}): + print('amongst', child.name, child.labels) + if postfix and child.name.endswith(postfix) and labels == child.labels: + return child + elif not postfix and labels == child.labels: return child @@ -103,7 +109,7 @@ class TestMetric(unittest.TestCase): metric.runtime(1) metric.runtime(2.6) metric_data = metric.to_metric_data() - self.assertEqual(choose('', metric_data, {'le': 2.5, 'ge': 1.0}).value, 1) + self.assertEqual(choose('', metric_data, {'le': 1.0, 'ge': 2.5}).value, 1) self.assertEqual(choose('sum', metric_data).value, 3.6) self.assertEqual(choose('count', metric_data).value, 2) @@ -112,10 +118,10 @@ class TestMetric(unittest.TestCase): metric.runtime(1, label='value') metric.runtime(2.6, label='value') metric_data = metric.to_metric_data() - self.assertEqual(choose('', metric_data, {'le': 2.5, 'ge': 1.0, 'label': 'value'}).value, 1) + self.assertEqual(choose('', metric_data, {'le': 1.0, 'ge': 2.5, 'label': 'value'}).value, 1) self.assertEqual(choose('sum', metric_data, {'label': 'value'}).value, 3.6) self.assertEqual(choose('count', metric_data, {'label': 'value'}).value, 2) - self.assertEqual(choose('total', metric_data, {'le': 2.5, 'ge': 1.0}).value, 1) + self.assertEqual(choose('total', metric_data, {'le': 1.0, 'ge': 2.5}).value, 1) self.assertEqual(choose('total.sum', metric_data).value, 3.6) self.assertEqual(choose('total.count', metric_data).value, 2) -- GitLab