diff options
| author | bd <bdunahu@operationnull.com> | 2025-07-19 22:21:10 -0600 |
|---|---|---|
| committer | bd <bdunahu@operationnull.com> | 2025-07-19 22:21:10 -0600 |
| commit | ac55d9ff0b588b91202ccad72ee71e508e33ad08 (patch) | |
| tree | 4933b49b67f1affa16f8e7c63e0d214bfa7d62e8 /t/test_functionality.py | |
| parent | d08f067f8f470b440b563293397116d6036c4d71 (diff) | |
Reformat repository to allow for new unit tests
Diffstat (limited to 't/test_functionality.py')
| -rw-r--r-- | t/test_functionality.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/t/test_functionality.py b/t/test_functionality.py new file mode 100644 index 0000000..5253534 --- /dev/null +++ b/t/test_functionality.py @@ -0,0 +1,57 @@ +import utils +import aiohttp +import asyncio + + +class BasicUsage(utils.AergiaUnitTestCase): + + def test_asyncless(self): + def a(): + x = 100 + while x > 0: + x -= 1 + + self.Aergia.start() + a() + self.Aergia.stop() + + samples = self.Aergia.get_samples() + self.assertFalse(samples) + + def test_sequential_tasks(self): + delay = 0.2 + num_times = 5 + + async def b(tot, num): + await asyncio.sleep(delay) + return tot + num + + async def a(): + tot = 0 + for i in range(num_times): + tot = await b(tot, i) + assert tot == 10 + + self.Aergia.start() + asyncio.run(a()) + self.Aergia.stop() + + samples = self.Aergia.get_samples() + + self.assertFuncContains('b', [self.expected_samples(delay * num_times)], + samples) + + def test_simultaneous_tasks(self): + delay = 0.2 + async def b(): await asyncio.sleep(delay) + async def a(): await asyncio.gather(b(), b(), b()) + + self.Aergia.start() + asyncio.run(a()) + self.Aergia.stop() + + samples = self.Aergia.get_samples() + + print(self.expected_samples(delay * 3)) + self.assertFuncContains('b', [self.expected_samples(delay * 3)], + samples) |
