(self)
| 196 | generate_latest(self.registry)) |
| 197 | |
| 198 | def test_timestamp(self): |
| 199 | class MyCollector: |
| 200 | def collect(self): |
| 201 | metric = Metric("ts", "help", 'untyped') |
| 202 | metric.add_sample("ts", {"foo": "a"}, 0, 123.456) |
| 203 | metric.add_sample("ts", {"foo": "b"}, 0, -123.456) |
| 204 | metric.add_sample("ts", {"foo": "c"}, 0, 123) |
| 205 | metric.add_sample("ts", {"foo": "d"}, 0, Timestamp(123, 456000000)) |
| 206 | metric.add_sample("ts", {"foo": "e"}, 0, Timestamp(123, 456000)) |
| 207 | metric.add_sample("ts", {"foo": "f"}, 0, Timestamp(123, 456)) |
| 208 | yield metric |
| 209 | |
| 210 | self.registry.register(MyCollector()) |
| 211 | self.assertEqual(b"""# HELP ts help |
| 212 | # TYPE ts untyped |
| 213 | ts{foo="a"} 0.0 123456 |
| 214 | ts{foo="b"} 0.0 -123456 |
| 215 | ts{foo="c"} 0.0 123000 |
| 216 | ts{foo="d"} 0.0 123456 |
| 217 | ts{foo="e"} 0.0 123000 |
| 218 | ts{foo="f"} 0.0 123000 |
| 219 | """, generate_latest(self.registry)) |
| 220 | |
| 221 | |
| 222 | class TestPushGateway(unittest.TestCase): |
nothing calls this directly
no test coverage detected