| 10 | |
| 11 | |
| 12 | class UnixSocketAPITest(BaseTest): |
| 13 | aptly_server = None |
| 14 | socket_path = "/tmp/_aptly_test.sock" |
| 15 | base_url = ("unix://%s" % socket_path) |
| 16 | aptly_out = None |
| 17 | debugOutput = True |
| 18 | |
| 19 | def prepare(self): |
| 20 | if self.aptly_server is None: |
| 21 | UnixSocketAPITest.aptly_out = TestOut() |
| 22 | self.aptly_server = self._start_process("aptly api serve -no-lock -listen=%s" % (self.base_url), stdout=UnixSocketAPITest.aptly_out, stderr=UnixSocketAPITest.aptly_out) |
| 23 | time.sleep(1) |
| 24 | else: |
| 25 | UnixSocketAPITest.aptly_out.clear() |
| 26 | super(UnixSocketAPITest, self).prepare() |
| 27 | |
| 28 | def debug_output(self): |
| 29 | return UnixSocketAPITest.aptly_out.get_contents() |
| 30 | |
| 31 | def shutdown(self): |
| 32 | if self.aptly_server is not None: |
| 33 | self.aptly_server.terminate() |
| 34 | self.aptly_server.wait() |
| 35 | self.aptly_server = None |
| 36 | super(UnixSocketAPITest, self).shutdown() |
| 37 | |
| 38 | def run(self): |
| 39 | pass |
| 40 | |
| 41 | """ |
| 42 | Verify we can listen on a unix domain socket. |
| 43 | """ |
| 44 | def check(self): |
| 45 | session = requests_unixsocket.Session() |
| 46 | r = session.get('http+unix://%s/api/version' % urllib.parse.quote(UnixSocketAPITest.socket_path, safe='')) |
| 47 | # Just needs to come back, we actually don't care much about the code. |
| 48 | # Only needs to verify that the socket is actually responding. |
| 49 | self.check_equal(r.json(), {'Version': os.environ['APTLY_VERSION']}) |
nothing calls this directly
no outgoing calls
no test coverage detected