"""Test Producer Helpers.""" import pytest from kafka_utils.producer.helpers import build_product_event from kafka_utils.producer.helpers import get_context def test_get_context(): """Test get_context.""" actual = get_context('value') assert actual == 'value' actual = get_context('key') assert actual == 'key' with pytest.raises(AttributeError): get_context('foo') def test_build_product_event(): """Test build_product_event.""" actual = build_product_event('foo', 'bar', {'baz': 'qux'}) assert actual.get('operation').get('type') == 'foo' assert actual.get('operation').get('timestamp') > 1 assert actual.get('operation').get('context') == 'bar' assert actual.get('payload') == {'baz': 'qux'}