Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #184

Merged
merged 10 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
- 3.8
- 3.9
- "3.10"
- pypy-3.7
- "3.11"
- pypy-3.9

steps:
- uses: actions/checkout@v2
Expand All @@ -39,7 +40,7 @@ jobs:
file: ./coverage.xml

autobahn:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
matrix:
side: [client, server]
Expand Down
4 changes: 3 additions & 1 deletion src/wsproto/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
"""

import zlib
from abc import ABC, abstractmethod
from typing import Optional, Tuple, Union

from .frame_protocol import CloseReason, FrameDecoder, FrameProtocol, Opcode, RsvBits


class Extension:
class Extension(ABC):
name: str

def enabled(self) -> bool:
return False

@abstractmethod
def offer(self) -> Union[bool, str]:
pass

Expand Down
25 changes: 16 additions & 9 deletions test/test_extensions.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
from typing import Union

from wsproto import extensions as wpext, frame_protocol as fp


class ConcreteExtension(wpext.Extension):
def offer(self) -> Union[bool, str]:
return "myext"


class TestExtension:
def test_enabled(self) -> None:
ext = wpext.Extension()
ext = ConcreteExtension()
assert not ext.enabled()

def test_offer(self) -> None:
ext = wpext.Extension()
assert ext.offer() is None
ext = ConcreteExtension()
assert ext.offer() == "myext"

def test_accept(self) -> None:
ext = wpext.Extension()
ext = ConcreteExtension()
offer = "myext"
assert ext.accept(offer) is None

def test_finalize(self) -> None:
ext = wpext.Extension()
ext = ConcreteExtension()
offer = "myext"
ext.finalize(offer)

def test_frame_inbound_header(self) -> None:
ext = wpext.Extension()
ext = ConcreteExtension()
result = ext.frame_inbound_header(None, None, None, None) # type: ignore[arg-type]
assert result == fp.RsvBits(False, False, False)

def test_frame_inbound_payload_data(self) -> None:
ext = wpext.Extension()
ext = ConcreteExtension()
data = b""
assert ext.frame_inbound_payload_data(None, data) == data # type: ignore[arg-type]

def test_frame_inbound_complete(self) -> None:
ext = wpext.Extension()
ext = ConcreteExtension()
assert ext.frame_inbound_complete(None, None) is None # type: ignore[arg-type]

def test_frame_outbound(self) -> None:
ext = wpext.Extension()
ext = ConcreteExtension()
rsv = fp.RsvBits(True, True, True)
data = b""
assert ext.frame_outbound(None, None, rsv, data, None) == ( # type: ignore[arg-type]
Expand Down
3 changes: 3 additions & 0 deletions test/test_frame_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,9 @@ def __init__(self) -> None:
def enabled(self) -> bool:
return True

def offer(self) -> Union[bool, str]:
return "fake"

def frame_inbound_header(
self,
proto: Union[fp.FrameDecoder, fp.FrameProtocol],
Expand Down
11 changes: 6 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[tox]
envlist = py37, py38, py39, py310, pypy3, lint, docs, packaging
envlist = py37, py38, py39, py310, py311, pypy3, lint, docs, packaging

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310, lint, docs, packaging
3.10: py310
3.11: py311, lint, docs, packaging
pypy3: pypy3

[testenv]
Expand Down Expand Up @@ -39,7 +40,7 @@ commands =
[testenv:docs]
deps =
sphinx
whitelist_externals = make
allowlist_externals = make
changedir = {toxinidir}/docs
commands =
make clean
Expand All @@ -51,7 +52,7 @@ deps =
check-manifest
readme-renderer
twine
whitelist_externals = rm
allowlist_externals = rm
commands =
rm -rf dist/
check-manifest
Expand All @@ -62,7 +63,7 @@ commands =
basepython = {[testenv:packaging]basepython}
deps =
{[testenv:packaging]deps}
whitelist_externals = {[testenv:packaging]whitelist_externals}
allowlist_externals = {[testenv:packaging]allowlist_externals}
commands =
{[testenv:packaging]commands}
twine upload dist/*
Expand Down