File: test_playback.py

package info (click to toggle)
python-proton-vpn-local-agent 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 496 kB
  • sloc: python: 380; makefile: 36; sh: 12
file content (41 lines) | stat: -rwxr-xr-x 797 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3

import asyncio
import local_agent
import json

responses = [
   [
      0,
      {
         "status" : {
            "state" : "connected"
         }
      }
   ],
   [
      1,
      {
         "status" : {
            "reason" : {
               "code" : 86111,
               "description" : "Max session reached for this plan",
               "final" : False
            },
            "state" : "hard-jailed"
         }
      }
   ]
]

# Connect to the VPN server
async def make_test_connection():
    agent_connection = await local_agent.AgentConnector().playback(json.dumps(responses))

    print(await agent_connection.read())
    print(await agent_connection.read())

    await agent_connection.close()

# execute the coroutine
asyncio.run(make_test_connection())