Skip to content

Commit

Permalink
Fix tests and coverage generation (still needs validation on Windows).
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdlaird committed Nov 29, 2022
1 parent fcbaf1a commit e60ae97
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ exclude_lines =
if 0:
if __name__ == .__main__.:

[xml]
output = _build/coverage/coverage.xml

[html]
title = pyngrok Coverage Report
directory = _build/coverage
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ jobs:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ 3.11 ]
include:
- python-version: 3.5
- python-version: "3.5"
os: ubuntu-20.04
- python-version: 3.7
- python-version: "3.7"
os: ubuntu-latest
- python-version: 3.9
- python-version: "3.9"
os: ubuntu-latest
- python-version: 3.10
- python-version: "3.10"
os: ubuntu-latest
- python-version: 3.11
- python-version: "3.11"
os: ubuntu-latest
- python-version: pypy-3.7
- python-version: "pypy-3.7"
os: ubuntu-latest

runs-on: ${{ matrix.os }}
Expand All @@ -49,11 +49,11 @@ jobs:
make install
- name: Run tests
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
nosetests --traverse-namespace
else
make test local
fi
# if [ "$RUNNER_OS" == "Windows" ]; then
# nosetests --traverse-namespace
# else
make test local
# fi
shell: bash
- name: Upload coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ test: install
@( \
source venv/bin/activate; \
coverage run -m unittest discover -b; \
coverage xml; \
coverage html; \
coverage report; \
)

docs: install
Expand Down
26 changes: 9 additions & 17 deletions tests/test_ngrok.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,8 @@ def test_api_request_timeout(self):
# THEN
self.assertIn("timed out", cm.exception.reason)

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_regional_tcp_v2(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

# GIVEN
self.assertEqual(len(process._current_processes.keys()), 0)
subdomain = self.create_unique_subdomain()
Expand All @@ -366,8 +365,8 @@ def test_regional_tcp_v2(self):
self.assertIn(".au.", ngrok_tunnel.public_url)
self.assertEqual(len(process._current_processes.keys()), 1)

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_regional_tcp_v3(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

# GIVEN
self.assertEqual(len(process._current_processes.keys()), 0)
Expand All @@ -388,9 +387,8 @@ def test_regional_tcp_v3(self):
self.assertIn(".au.", ngrok_tunnel.public_url)
self.assertEqual(len(process._current_processes.keys()), 1)

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_regional_subdomain(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

# GIVEN
self.assertEqual(len(process._current_processes.keys()), 0)
subdomain = self.create_unique_subdomain()
Expand All @@ -411,9 +409,8 @@ def test_regional_subdomain(self):
self.assertIn(subdomain, url)
self.assertEqual(len(process._current_processes.keys()), 1)

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_connect_fileserver(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

# GIVEN
self.assertEqual(len(process._current_processes.keys()), 0)
pyngrok_config = self.copy_with_updates(self.pyngrok_config_v2, auth_token=os.environ["NGROK_AUTHTOKEN"])
Expand All @@ -436,9 +433,8 @@ def test_connect_fileserver(self):
self.assertIn('http://', ngrok_tunnel.public_url)
self.assertEqual(len(process._current_processes.keys()), 1)

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_disconnect_fileserver(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

# GIVEN
self.assertEqual(len(process._current_processes.keys()), 0)
pyngrok_config = self.copy_with_updates(self.pyngrok_config_v2, auth_token=os.environ["NGROK_AUTHTOKEN"])
Expand All @@ -454,9 +450,8 @@ def test_disconnect_fileserver(self):
# There is still one tunnel left, as we only disconnected the http tunnel
self.assertEqual(len(tunnels), 1)

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_get_tunnel_fileserver(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

# GIVEN
self.assertEqual(len(process._current_processes.keys()), 0)
pyngrok_config = self.copy_with_updates(self.pyngrok_config_v2, auth_token=os.environ["NGROK_AUTHTOKEN"])
Expand Down Expand Up @@ -489,9 +484,8 @@ def test_ngrok_tunnel_refresh_metrics(self):
self.assertGreater(ngrok_tunnel.metrics.get("http").get("count"), 0)
self.assertGreater(ngrok_tunnel.data["metrics"].get("http").get("count"), 0)

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_tunnel_definitions_v2(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

subdomain = self.create_unique_subdomain()

# GIVEN
Expand Down Expand Up @@ -530,9 +524,8 @@ def test_tunnel_definitions_v2(self):
self.assertEqual(ssh_tunnel.proto, config["tunnels"]["tcp-tunnel"]["proto"])
self.assertTrue(ssh_tunnel.public_url.startswith("tcp://"))

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_tunnel_definitions_v3(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

subdomain = self.create_unique_subdomain()

# GIVEN
Expand Down Expand Up @@ -571,9 +564,8 @@ def test_tunnel_definitions_v3(self):
self.assertEqual(ssh_tunnel.proto, config["tunnels"]["tcp-tunnel"]["proto"])
self.assertTrue(ssh_tunnel.public_url.startswith("tcp://"))

@unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")
def test_tunnel_definitions_pyngrok_default_with_overrides(self):
unittest.skipIf("NGROK_AUTHTOKEN" not in os.environ, "NGROK_AUTHTOKEN environment variable not set")

subdomain = self.create_unique_subdomain()

# GIVEN
Expand Down

0 comments on commit e60ae97

Please sign in to comment.