.generator/conftest.py in datadog_api_client-2.10.0 vs .generator/conftest.py in datadog_api_client-2.11.0
- old
+ new
@@ -11,10 +11,11 @@
import pytest
from dateutil.relativedelta import relativedelta
from jinja2 import Environment, FileSystemLoader, Template
from pytest_bdd import given, parsers, then, when
+import hashlib
from generator import openapi
from generator.formatter import camel_case, snake_case, untitle_case, format_parameters, format_data_with_schema
@@ -210,17 +211,19 @@
replace_values = MarkUsed()
imports = defaultdict(set)
given = defaultdict(dict)
+ unique_hash = hashlib.sha256(unique.encode("utf-8")).hexdigest()[:16]
ctx = {
"unique": unique,
"unique_lower": unique.lower(),
"unique_upper": unique.upper(),
"unique_alnum": PATTERN_ALPHANUM.sub("", unique),
"unique_lower_alnum": PATTERN_ALPHANUM.sub("", unique).lower(),
"unique_upper_alnum": PATTERN_ALPHANUM.sub("", unique).upper(),
+ "unique_hash": unique_hash,
"timestamp": relative_time(imports, replace_values, freezed_time, False),
"timeISO": relative_time(imports, replace_values, freezed_time, True),
"_replace_values": replace_values,
"_imports": imports,
"_given": given,
@@ -454,5 +457,13 @@
@then(parsers.parse('the response "{response_path}" is false'))
def expect_false(context, response_path):
"""Check that a response attribute is false."""
+
+@then(parsers.parse('the response "{response_path}" has item with field "{key_path}" with value {value}'))
+def expect_array_contains_object(context, response_path, key_path, value):
+ """Check that a response attribute contains an object with the specified key and value."""
+
+@then(parsers.parse('the response "{response_path}" array contains value {value}'))
+def expect_array_contains_value(context, response_path, value):
+ """Check that a response array contains the specified value."""