aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/tests
diff options
context:
space:
mode:
authorHunternif2021-08-06 23:05:50 +0100
committerHunternif2021-08-06 23:05:50 +0100
commitcf26cc74a7a0252ff9329aff0c2f932f5da57a4f (patch)
tree84f530c2fcc921fa56ba496f0059fa9707b4e948 /server/szurubooru/tests
parent8c63b7502b5cab79ba2adc25821b952b44308e00 (diff)
server: update ' to "
Diffstat (limited to 'server/szurubooru/tests')
-rw-r--r--server/szurubooru/tests/func/test_metrics.py110
1 files changed, 55 insertions, 55 deletions
diff --git a/server/szurubooru/tests/func/test_metrics.py b/server/szurubooru/tests/func/test_metrics.py
index 22f3e38..17b20ef 100644
--- a/server/szurubooru/tests/func/test_metrics.py
+++ b/server/szurubooru/tests/func/test_metrics.py
@@ -10,14 +10,14 @@ def test_serialize_metric(tag_factory):
db.session.flush()
result = metrics.serialize_metric(metric)
assert result == {
- 'version': 1,
- 'min': 1,
- 'max': 2,
+ "version": 1,
+ "min": 1,
+ "max": 2,
}
def test_serialize_post_metric(post_factory, tag_factory, metric_factory):
- tag = tag_factory(names=['mytag'])
+ tag = tag_factory(names=["mytag"])
post = post_factory(id=456, tags=[tag])
metric = metric_factory(tag)
post_metric = model.PostMetric(post=post, metric=metric, value=-12.3)
@@ -25,14 +25,14 @@ def test_serialize_post_metric(post_factory, tag_factory, metric_factory):
db.session.flush()
result = metrics.serialize_post_metric(post_metric)
assert result == {
- 'tag_name': 'mytag',
- 'post_id': 456,
- 'value': -12.3,
+ "tag_name": "mytag",
+ "post_id": 456,
+ "value": -12.3,
}
def test_serialize_post_metric_range(post_factory, tag_factory, metric_factory):
- tag = tag_factory(names=['mytag'])
+ tag = tag_factory(names=["mytag"])
post = post_factory(id=456, tags=[tag])
metric = metric_factory(tag)
post_metric_range = model.PostMetricRange(
@@ -41,20 +41,20 @@ def test_serialize_post_metric_range(post_factory, tag_factory, metric_factory):
db.session.flush()
result = metrics.serialize_post_metric_range(post_metric_range)
assert result == {
- 'tag_name': 'mytag',
- 'post_id': 456,
- 'low': -1.2,
- 'high': 3.4
+ "tag_name": "mytag",
+ "post_id": 456,
+ "low": -1.2,
+ "high": 3.4
}
def test_try_get_metric_by_tag_name(tag_factory, metric_factory):
- tag = tag_factory(names=['mytag'])
+ tag = tag_factory(names=["mytag"])
metric = metric_factory(tag)
db.session.add_all([tag, metric])
db.session.flush()
- assert metrics.try_get_metric_by_tag_name('unknown') is None
- assert metrics.try_get_metric_by_tag_name('mytag') is metric
+ assert metrics.try_get_metric_by_tag_name("unknown") is None
+ assert metrics.try_get_metric_by_tag_name("mytag") is metric
def test_try_get_post_metric(
@@ -95,13 +95,13 @@ def test_get_all_metrics(metric_factory):
def test_get_all_metric_tag_names(tag_factory, metric_factory):
- tag1 = tag_factory(names=['abc', 'def'])
- tag2 = tag_factory(names=['ghi'])
+ tag1 = tag_factory(names=["abc", "def"])
+ tag2 = tag_factory(names=["ghi"])
metric1 = metric_factory(tag=tag1)
metric2 = metric_factory(tag=tag2)
db.session.add_all([metric1, metric2])
db.session.flush()
- assert metrics.get_all_metric_tag_names() == ['abc', 'def', 'ghi']
+ assert metrics.get_all_metric_tag_names() == ["abc", "def", "ghi"]
def test_create_metric(tag_factory):
@@ -131,7 +131,7 @@ def test_create_metric_with_invalid_params(tag_factory):
def test_update_or_create_metric(tag_factory):
tag = tag_factory()
db.session.add(tag)
- new_metric = metrics.update_or_create_metric(tag, {'min': 1, 'max': 2})
+ new_metric = metrics.update_or_create_metric(tag, {"min": 1, "max": 2})
assert new_metric is not None
db.session.flush()
assert tag.metric is not None
@@ -139,7 +139,7 @@ def test_update_or_create_metric(tag_factory):
assert tag.metric.max == 2
assert tag.metric.version == 1
- new_metric = metrics.update_or_create_metric(tag, {'min': 3, 'max': 4})
+ new_metric = metrics.update_or_create_metric(tag, {"min": 3, "max": 4})
assert new_metric is None
db.session.flush()
assert tag.metric.min == 3
@@ -147,8 +147,8 @@ def test_update_or_create_metric(tag_factory):
assert tag.metric.version == 2
-@pytest.mark.parametrize('params', [
- {'min': 1}, {'max': 2}, {'min': 2, 'max': 1}
+@pytest.mark.parametrize("params", [
+ {"min": 1}, {"max": 2}, {"min": 2, "max": 1}
])
def test_update_or_create_metric_with_invalid_params(tag_factory, params):
tag = tag_factory()
@@ -206,19 +206,19 @@ def test_update_or_create_post_metric_update(post_factory, metric_factory):
def test_update_or_create_post_metrics_missing_tag(
post_factory, tag_factory, metric_factory):
post = post_factory()
- tag = tag_factory(names=['tag1'])
+ tag = tag_factory(names=["tag1"])
metric = metric_factory(tag)
db.session.add(metric)
db.session.flush()
- data = [{'tag_name': 'tag1', 'value': 1.5}]
+ data = [{"tag_name": "tag1", "value": 1.5}]
with pytest.raises(metrics.PostMissingTagError):
metrics.update_or_create_post_metrics(post, data)
-@pytest.mark.parametrize('params', [
+@pytest.mark.parametrize("params", [
[{}],
- [{'tag_name': 'tag'}],
- [{'value': 1.5}]
+ [{"tag_name": "tag"}],
+ [{"value": 1.5}]
])
def test_update_or_create_post_metrics_with_missing_fields(
params, post_factory):
@@ -229,19 +229,19 @@ def test_update_or_create_post_metrics_with_missing_fields(
def test_update_or_create_post_metrics_with_invalid_tag(
post_factory, tag_factory):
- tag = tag_factory(names=['tag1'])
+ tag = tag_factory(names=["tag1"])
post = post_factory(tags=[tag])
db.session.add(tag)
db.session.flush()
- data = [{'tag_name': 'tag1', 'value': 2}]
+ data = [{"tag_name": "tag1", "value": 2}]
with pytest.raises(metrics.MetricDoesNotExistsError):
metrics.update_or_create_post_metrics(post, data)
def test_update_or_create_post_metrics(
post_factory, tag_factory, metric_factory):
- tag1 = tag_factory(names=['tag1'])
- tag2 = tag_factory(names=['tag2'])
+ tag1 = tag_factory(names=["tag1"])
+ tag2 = tag_factory(names=["tag2"])
post = post_factory(tags=[tag1, tag2])
metric1 = metric_factory(tag1)
metric2 = metric_factory(tag2)
@@ -249,8 +249,8 @@ def test_update_or_create_post_metrics(
db.session.flush()
data = [
- {'tag_name': 'tag1', 'value': 1.2},
- {'tag_name': 'tag2', 'value': 3.4},
+ {"tag_name": "tag1", "value": 1.2},
+ {"tag_name": "tag2", "value": 3.4},
]
metrics.update_or_create_post_metrics(post, data)
db.session.flush()
@@ -262,8 +262,8 @@ def test_update_or_create_post_metrics(
def test_update_or_create_post_metrics_with_trim(
post_factory, tag_factory, metric_factory, post_metric_factory):
- tag1 = tag_factory(names=['tag1'])
- tag2 = tag_factory(names=['tag2'])
+ tag1 = tag_factory(names=["tag1"])
+ tag2 = tag_factory(names=["tag2"])
post = post_factory(tags=[tag1, tag2])
metric1 = metric_factory(tag1)
metric2 = metric_factory(tag2)
@@ -275,7 +275,7 @@ def test_update_or_create_post_metrics_with_trim(
assert post.metrics[0].value == 1.2
data = [
- {'tag_name': 'tag2', 'value': 3.4},
+ {"tag_name": "tag2", "value": 3.4},
]
metrics.update_or_create_post_metrics(post, data)
db.session.flush()
@@ -295,7 +295,7 @@ def test_update_or_create_post_metric_range_without_tag(
metrics.update_or_create_post_metric_range(post, metric, 2, 3)
-@pytest.mark.parametrize('low, high', [
+@pytest.mark.parametrize("low, high", [
(-99, 1), (1, 99),
])
def test_update_or_create_post_metric_range_with_values_out_of_range(
@@ -339,24 +339,24 @@ def test_update_or_create_post_metric_range_update(
def test_update_or_create_post_metric_ranges_missing_tag(
post_factory, tag_factory, metric_factory):
post = post_factory()
- tag = tag_factory(names=['tag1'])
+ tag = tag_factory(names=["tag1"])
metric = metric_factory(tag)
db.session.add(metric)
db.session.flush()
- data = [{'tag_name': 'tag1', 'low': 2, 'high': 3}]
+ data = [{"tag_name": "tag1", "low": 2, "high": 3}]
with pytest.raises(metrics.PostMissingTagError):
metrics.update_or_create_post_metric_ranges(post, data)
-@pytest.mark.parametrize('params', [
+@pytest.mark.parametrize("params", [
[{}],
- [{'tag_name': 'tag'}],
- [{'tag_name': 'tag', 'low': 2}],
- [{'low': 2, 'high': 3}],
+ [{"tag_name": "tag"}],
+ [{"tag_name": "tag", "low": 2}],
+ [{"low": 2, "high": 3}],
])
def test_update_or_create_post_metric_ranges_with_missing_fields(
params, post_factory, tag_factory):
- tag = tag_factory(names=['tag'])
+ tag = tag_factory(names=["tag"])
post = post_factory(tags=[tag])
with pytest.raises(metrics.InvalidMetricError):
metrics.update_or_create_post_metric_ranges(post, params)
@@ -364,24 +364,24 @@ def test_update_or_create_post_metric_ranges_with_missing_fields(
def test_update_or_create_post_metric_ranges_with_invalid_tag(
post_factory, tag_factory):
- tag = tag_factory(names=['tag1'])
+ tag = tag_factory(names=["tag1"])
post = post_factory(tags=[tag])
db.session.add(tag)
db.session.flush()
- data = [{'tag_name': 'tag1', 'low': 2, 'high': 3}]
+ data = [{"tag_name": "tag1", "low": 2, "high": 3}]
with pytest.raises(metrics.MetricDoesNotExistsError):
metrics.update_or_create_post_metric_ranges(post, data)
def test_update_or_create_post_metric_ranges_with_invalid_values(
post_factory, tag_factory, metric_factory):
- tag = tag_factory(names=['tag1'])
+ tag = tag_factory(names=["tag1"])
post = post_factory(tags=[tag])
metric = metric_factory(tag=tag)
db.session.add_all([metric, tag])
db.session.flush()
data = [
- {'tag_name': 'tag1', 'low': 4, 'high': 2},
+ {"tag_name": "tag1", "low": 4, "high": 2},
]
with pytest.raises(metrics.InvalidMetricError):
metrics.update_or_create_post_metric_ranges(post, data)
@@ -389,8 +389,8 @@ def test_update_or_create_post_metric_ranges_with_invalid_values(
def test_update_or_create_post_metric_ranges(
post_factory, tag_factory, metric_factory):
- tag1 = tag_factory(names=['tag1'])
- tag2 = tag_factory(names=['tag2'])
+ tag1 = tag_factory(names=["tag1"])
+ tag2 = tag_factory(names=["tag2"])
post = post_factory(tags=[tag1, tag2])
metric1 = metric_factory(tag1)
metric2 = metric_factory(tag2)
@@ -398,8 +398,8 @@ def test_update_or_create_post_metric_ranges(
db.session.flush()
data = [
- {'tag_name': 'tag1', 'low': 2, 'high': 3},
- {'tag_name': 'tag2', 'low': 4, 'high': 5},
+ {"tag_name": "tag1", "low": 2, "high": 3},
+ {"tag_name": "tag2", "low": 4, "high": 5},
]
metrics.update_or_create_post_metric_ranges(post, data)
db.session.flush()
@@ -413,8 +413,8 @@ def test_update_or_create_post_metric_ranges(
def test_update_or_create_post_metric_ranges_with_trim(
post_factory, tag_factory, metric_factory, post_metric_range_factory):
- tag1 = tag_factory(names=['tag1'])
- tag2 = tag_factory(names=['tag2'])
+ tag1 = tag_factory(names=["tag1"])
+ tag2 = tag_factory(names=["tag2"])
post = post_factory(tags=[tag1, tag2])
metric1 = metric_factory(tag1)
metric2 = metric_factory(tag2)
@@ -428,7 +428,7 @@ def test_update_or_create_post_metric_ranges_with_trim(
assert post.metric_ranges[0].high == 2
data = [
- {'tag_name': 'tag2', 'low': 3, 'high': 4},
+ {"tag_name": "tag2", "low": 3, "high": 4},
]
metrics.update_or_create_post_metric_ranges(post, data)
db.session.flush()

© 2015 - 2026 Jakob L. Kreuze