import unittest
import pytest
PORT = 4318
class TestOtlpPushAlways(unittest.TestCase):
def test_historical_mode_drains_without_connecting(self):
from wingfoil import ticker
node = ticker(0.01).count().otlp_push(
"hist_metric",
endpoint="http://127.0.0.1:1",
service_name="wingfoil-py-test",
)
node.run(realtime=False, start=0.0, cycles=5)
def test_otlp_push_returns_node(self):
from wingfoil import ticker
from wingfoil._wingfoil import Node
node = ticker(0.1).count().otlp_push(
"type_check_metric",
endpoint="http://127.0.0.1:1",
service_name="wingfoil-py-test",
)
self.assertIsInstance(node, Node)
@pytest.mark.requires_otel
class TestOtlpPush(unittest.TestCase):
def test_push_sends_without_error(self):
from wingfoil import ticker
node = ticker(0.1).count().otlp_push(
"test_counter",
endpoint="http://localhost:4318",
service_name="wingfoil-py-test",
)
node.run(realtime=True, cycles=5)
def test_push_stream_directly(self):
from wingfoil import constant
node = constant(42).otlp_push(
"constant_gauge",
endpoint="http://localhost:4318",
service_name="wingfoil-py-test",
)
node.run(realtime=True, cycles=1)
if __name__ == "__main__":
unittest.main()