sipmessage 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sipmessage-0.1.0/LICENSE +22 -0
- sipmessage-0.1.0/MANIFEST.in +7 -0
- sipmessage-0.1.0/Makefile +100 -0
- sipmessage-0.1.0/PKG-INFO +34 -0
- sipmessage-0.1.0/README.rst +7 -0
- sipmessage-0.1.0/pyproject.toml +74 -0
- sipmessage-0.1.0/setup.cfg +4 -0
- sipmessage-0.1.0/setup.py +3 -0
- sipmessage-0.1.0/src/sipmessage/__init__.py +8 -0
- sipmessage-0.1.0/src/sipmessage/parameters.py +21 -0
- sipmessage-0.1.0/src/sipmessage/uri.py +80 -0
- sipmessage-0.1.0/src/sipmessage.egg-info/PKG-INFO +34 -0
- sipmessage-0.1.0/src/sipmessage.egg-info/SOURCES.txt +18 -0
- sipmessage-0.1.0/src/sipmessage.egg-info/dependency_links.txt +1 -0
- sipmessage-0.1.0/src/sipmessage.egg-info/requires.txt +7 -0
- sipmessage-0.1.0/src/sipmessage.egg-info/top_level.txt +1 -0
- sipmessage-0.1.0/tests/__init__.py +0 -0
- sipmessage-0.1.0/tests/test_parameters.py +20 -0
- sipmessage-0.1.0/tests/test_public_api.py +9 -0
- sipmessage-0.1.0/tests/test_uri.py +99 -0
sipmessage-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) Spacinov SAS
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
14
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
15
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
17
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
18
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
19
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
20
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
22
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
|
|
2
|
+
SRC_DIRS = src/
|
|
3
|
+
TEST_DIRS = tests/
|
|
4
|
+
PYTHON_DIRS = $(SRC_DIRS) $(TEST_DIRS)
|
|
5
|
+
PYTHON_FILES = $(shell find $(PYTHON_DIRS) -name '*.py') setup.py
|
|
6
|
+
|
|
7
|
+
.DEFAULT_GOAL: all
|
|
8
|
+
|
|
9
|
+
all: test lint
|
|
10
|
+
|
|
11
|
+
help:
|
|
12
|
+
@echo "Simply run `make` to run all linting and testing tasks."
|
|
13
|
+
@echo ""
|
|
14
|
+
@echo "You may also run `make --jobs 4 --keep-going` for a faster run."
|
|
15
|
+
@echo ""
|
|
16
|
+
@echo "Extra targets:"
|
|
17
|
+
@echo "- ci-lint / ci-test: run tasks for continuous integration"
|
|
18
|
+
@echo "- clean: Remove temporary files"
|
|
19
|
+
@echo "- lint-pkg: Check the packaging setup"
|
|
20
|
+
@echo "- setup-test: Install all development dependencies"
|
|
21
|
+
|
|
22
|
+
.PHONY: all help
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Cleanup
|
|
26
|
+
|
|
27
|
+
clean:
|
|
28
|
+
-rm .*-done
|
|
29
|
+
coverage erase
|
|
30
|
+
|
|
31
|
+
.PHONY: clean
|
|
32
|
+
|
|
33
|
+
# Dependencies
|
|
34
|
+
|
|
35
|
+
setup-test: .pip-done
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
.pip-done: setup.py pyproject.toml
|
|
39
|
+
pip install --upgrade pip setuptools wheel
|
|
40
|
+
pip install --editable .[dev]
|
|
41
|
+
@touch $@
|
|
42
|
+
|
|
43
|
+
.PHONY: setup-test
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Linting
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
lint: .ruff-format-done .ruff-check-done
|
|
51
|
+
|
|
52
|
+
ci-lint: lint lint-pkg
|
|
53
|
+
|
|
54
|
+
.ruff-format-done: $(PYTHON_FILES) | .pip-done
|
|
55
|
+
ruff format --diff $+
|
|
56
|
+
@touch $@
|
|
57
|
+
|
|
58
|
+
.ruff-check-done: $(PYTHON_FILES) | .pip-done
|
|
59
|
+
ruff check --diff $+
|
|
60
|
+
@touch $@
|
|
61
|
+
|
|
62
|
+
lint-pkg:
|
|
63
|
+
check-manifest
|
|
64
|
+
pyroma --directory .
|
|
65
|
+
|
|
66
|
+
.PHONY: ci-lint lint lint-pkg
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# Tests
|
|
70
|
+
|
|
71
|
+
test: test-types test-unittest
|
|
72
|
+
|
|
73
|
+
ci-test: test-types xmlcov
|
|
74
|
+
|
|
75
|
+
test-types: .mypy-done
|
|
76
|
+
|
|
77
|
+
test-unittest: .coverage
|
|
78
|
+
|
|
79
|
+
.coverage: $(PYTHON_FILES) | .pip-done
|
|
80
|
+
coverage run --module unittest discover -vv $(TEST_DIRS)
|
|
81
|
+
coverage report
|
|
82
|
+
|
|
83
|
+
.mypy-done: $(PYTHON_FILES) | .pip-done
|
|
84
|
+
mypy $(PYTHON_DIRS)
|
|
85
|
+
@touch $@
|
|
86
|
+
|
|
87
|
+
htmlcov: htmlcov/index.html
|
|
88
|
+
|
|
89
|
+
htmlcov/index.html: .coverage
|
|
90
|
+
coverage html
|
|
91
|
+
|
|
92
|
+
xmlcov: coverage.xml
|
|
93
|
+
|
|
94
|
+
coverage.xml: .coverage
|
|
95
|
+
coverage xml
|
|
96
|
+
|
|
97
|
+
.PHONY: htmlcov xmlcov
|
|
98
|
+
|
|
99
|
+
.PHONY: ci-test test test-types test-unittest
|
|
100
|
+
.PHONY: test test-types test-unittest
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sipmessage
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure python parsing of SIP messages and headers
|
|
5
|
+
Author-email: Spacinov Engineering <opensource@spacinov.com>
|
|
6
|
+
License: BSD License
|
|
7
|
+
Project-URL: Homepage, https://sipmessage.readthedocs.io/
|
|
8
|
+
Project-URL: Documentation, https://sipmessage.readthedocs.io/
|
|
9
|
+
Project-URL: Repository, https://github.com/spacinov/sipmessage
|
|
10
|
+
Project-URL: Issues, https://github.com/spacinov/sipmessage/issues
|
|
11
|
+
Keywords: SIP,RFC3261
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: Intended Audience :: Telecommunications Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Communications :: Telephony
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/x-rst
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
|
|
28
|
+
==========
|
|
29
|
+
sipmessage
|
|
30
|
+
==========
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
The ``sipmessage`` project provides a set of Python helpers and structures
|
|
34
|
+
for parsing SIP messages.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools >= 61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
# Version
|
|
7
|
+
name = "sipmessage"
|
|
8
|
+
version = "0.1.0"
|
|
9
|
+
|
|
10
|
+
# Dependencies
|
|
11
|
+
dependencies = []
|
|
12
|
+
requires-python = ">= 3.10"
|
|
13
|
+
|
|
14
|
+
# Development
|
|
15
|
+
authors = [
|
|
16
|
+
{name = "Spacinov Engineering", email="opensource@spacinov.com"},
|
|
17
|
+
]
|
|
18
|
+
license = {text = "BSD License"}
|
|
19
|
+
|
|
20
|
+
# Description
|
|
21
|
+
description = "Pure python parsing of SIP messages and headers"
|
|
22
|
+
readme = {file = "README.rst", content-type = "text/x-rst"}
|
|
23
|
+
|
|
24
|
+
# PyPI
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 4 - Beta",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"Intended Audience :: System Administrators",
|
|
29
|
+
"Intended Audience :: Telecommunications Industry",
|
|
30
|
+
"License :: OSI Approved :: BSD License",
|
|
31
|
+
"Operating System :: OS Independent",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Topic :: Communications :: Telephony",
|
|
36
|
+
"Typing :: Typed",
|
|
37
|
+
]
|
|
38
|
+
keywords = ["SIP", "RFC3261"]
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
dev = [
|
|
42
|
+
"check-manifest",
|
|
43
|
+
"coverage",
|
|
44
|
+
"mypy",
|
|
45
|
+
"pyroma",
|
|
46
|
+
"ruff",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://sipmessage.readthedocs.io/"
|
|
51
|
+
Documentation = "https://sipmessage.readthedocs.io/"
|
|
52
|
+
Repository = "https://github.com/spacinov/sipmessage"
|
|
53
|
+
Issues = "https://github.com/spacinov/sipmessage/issues"
|
|
54
|
+
|
|
55
|
+
[tool.coverage.run]
|
|
56
|
+
include = ["src/*"]
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.packages.find]
|
|
59
|
+
where = ["src"]
|
|
60
|
+
include = ["sipmessage"]
|
|
61
|
+
namespaces = false
|
|
62
|
+
|
|
63
|
+
[tool.mypy]
|
|
64
|
+
ignore_missing_imports = false
|
|
65
|
+
strict = true
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint]
|
|
68
|
+
select = [
|
|
69
|
+
"E", # pycodestyle
|
|
70
|
+
"F", # Pyflakes
|
|
71
|
+
"W", # pycodestyle
|
|
72
|
+
"I", # isort
|
|
73
|
+
"T20", # flake8-print
|
|
74
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) Spacinov SAS
|
|
3
|
+
# Distributed under the 2-clause BSD license
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Parameters(dict[str, str | None]):
|
|
8
|
+
@classmethod
|
|
9
|
+
def parse(cls, val: str) -> "Parameters":
|
|
10
|
+
p = cls()
|
|
11
|
+
if val:
|
|
12
|
+
for bit in val.split(";"):
|
|
13
|
+
if "=" in bit:
|
|
14
|
+
k, v = bit.split("=", 1)
|
|
15
|
+
else:
|
|
16
|
+
k, v = bit, None
|
|
17
|
+
p[k] = v
|
|
18
|
+
return p
|
|
19
|
+
|
|
20
|
+
def __str__(self) -> str:
|
|
21
|
+
return ";".join([k if v is None else (k + "=" + v) for k, v in self.items()])
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) Spacinov SAS
|
|
3
|
+
# Distributed under the 2-clause BSD license
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
import dataclasses
|
|
7
|
+
import urllib.parse
|
|
8
|
+
|
|
9
|
+
from .parameters import Parameters
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclasses.dataclass
|
|
13
|
+
class URI:
|
|
14
|
+
scheme: str
|
|
15
|
+
host: str
|
|
16
|
+
user: str | None = None
|
|
17
|
+
password: str | None = None
|
|
18
|
+
port: int | None = None
|
|
19
|
+
parameters: Parameters = dataclasses.field(default_factory=Parameters)
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def parse(cls, value: str) -> "URI":
|
|
23
|
+
parsed = urllib.parse.urlparse(value)
|
|
24
|
+
if "@" in parsed.path:
|
|
25
|
+
user_password, host_port = parsed.path.split("@")
|
|
26
|
+
if ":" in user_password:
|
|
27
|
+
user, password = user_password.split(":")
|
|
28
|
+
else:
|
|
29
|
+
user = user_password
|
|
30
|
+
password = None
|
|
31
|
+
else:
|
|
32
|
+
host_port = parsed.path
|
|
33
|
+
user = None
|
|
34
|
+
password = None
|
|
35
|
+
if ":" in host_port:
|
|
36
|
+
host, port_ = host_port.split(":")
|
|
37
|
+
port = int(port_)
|
|
38
|
+
else:
|
|
39
|
+
host = host_port
|
|
40
|
+
port = None
|
|
41
|
+
return cls(
|
|
42
|
+
scheme=parsed.scheme,
|
|
43
|
+
host=host,
|
|
44
|
+
port=port,
|
|
45
|
+
user=user,
|
|
46
|
+
password=password,
|
|
47
|
+
parameters=Parameters.parse(parsed.params),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def global_phone_number(self) -> str | None:
|
|
52
|
+
"""
|
|
53
|
+
The global phone number (E.164) of this URI, if described by the URI.
|
|
54
|
+
|
|
55
|
+
This is one of the possibilities for the `userinfo` part described in RFC3261,
|
|
56
|
+
with telephone-subscriber in RFC2806:
|
|
57
|
+
|
|
58
|
+
> userinfo = user | telephone-subscriber
|
|
59
|
+
> telephone-subscriber = global-phone-number | local-phone-number
|
|
60
|
+
"""
|
|
61
|
+
if self.user is None:
|
|
62
|
+
return None
|
|
63
|
+
if self.user[0] == "+" and self.user[1:].isnumeric():
|
|
64
|
+
return self.user
|
|
65
|
+
else:
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
def __str__(self) -> str:
|
|
69
|
+
s = self.scheme + ":"
|
|
70
|
+
if self.user is not None:
|
|
71
|
+
s += self.user
|
|
72
|
+
if self.password is not None:
|
|
73
|
+
s += ":" + self.password
|
|
74
|
+
s += "@"
|
|
75
|
+
s += self.host
|
|
76
|
+
if self.port is not None:
|
|
77
|
+
s += ":" + str(self.port)
|
|
78
|
+
if self.parameters:
|
|
79
|
+
s += ";" + str(self.parameters)
|
|
80
|
+
return s
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sipmessage
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure python parsing of SIP messages and headers
|
|
5
|
+
Author-email: Spacinov Engineering <opensource@spacinov.com>
|
|
6
|
+
License: BSD License
|
|
7
|
+
Project-URL: Homepage, https://sipmessage.readthedocs.io/
|
|
8
|
+
Project-URL: Documentation, https://sipmessage.readthedocs.io/
|
|
9
|
+
Project-URL: Repository, https://github.com/spacinov/sipmessage
|
|
10
|
+
Project-URL: Issues, https://github.com/spacinov/sipmessage/issues
|
|
11
|
+
Keywords: SIP,RFC3261
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: Intended Audience :: Telecommunications Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Communications :: Telephony
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/x-rst
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
|
|
28
|
+
==========
|
|
29
|
+
sipmessage
|
|
30
|
+
==========
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
The ``sipmessage`` project provides a set of Python helpers and structures
|
|
34
|
+
for parsing SIP messages.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
Makefile
|
|
4
|
+
README.rst
|
|
5
|
+
pyproject.toml
|
|
6
|
+
setup.py
|
|
7
|
+
src/sipmessage/__init__.py
|
|
8
|
+
src/sipmessage/parameters.py
|
|
9
|
+
src/sipmessage/uri.py
|
|
10
|
+
src/sipmessage.egg-info/PKG-INFO
|
|
11
|
+
src/sipmessage.egg-info/SOURCES.txt
|
|
12
|
+
src/sipmessage.egg-info/dependency_links.txt
|
|
13
|
+
src/sipmessage.egg-info/requires.txt
|
|
14
|
+
src/sipmessage.egg-info/top_level.txt
|
|
15
|
+
tests/__init__.py
|
|
16
|
+
tests/test_parameters.py
|
|
17
|
+
tests/test_public_api.py
|
|
18
|
+
tests/test_uri.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sipmessage
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) Spacinov SAS
|
|
3
|
+
# Distributed under the 2-clause BSD license
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
import unittest
|
|
7
|
+
|
|
8
|
+
from sipmessage.parameters import Parameters
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ParametersTest(unittest.TestCase):
|
|
12
|
+
def test_empty(self) -> None:
|
|
13
|
+
parameters = Parameters.parse("")
|
|
14
|
+
self.assertEqual(parameters, {})
|
|
15
|
+
self.assertEqual(str(parameters), "")
|
|
16
|
+
|
|
17
|
+
def test_not_empty(self) -> None:
|
|
18
|
+
parameters = Parameters.parse("foo=1;bar")
|
|
19
|
+
self.assertEqual(parameters, {"foo": "1", "bar": None})
|
|
20
|
+
self.assertEqual(str(parameters), "foo=1;bar")
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) Spacinov SAS
|
|
3
|
+
# Distributed under the 2-clause BSD license
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
import unittest
|
|
7
|
+
|
|
8
|
+
from sipmessage.uri import URI
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class URITest(unittest.TestCase):
|
|
12
|
+
def test_host(self) -> None:
|
|
13
|
+
uri = URI.parse("sip:atlanta.com")
|
|
14
|
+
|
|
15
|
+
self.assertEqual(uri.host, "atlanta.com")
|
|
16
|
+
self.assertEqual(uri.port, None)
|
|
17
|
+
self.assertEqual(uri.user, None)
|
|
18
|
+
self.assertEqual(uri.password, None)
|
|
19
|
+
self.assertEqual(uri.parameters, {})
|
|
20
|
+
|
|
21
|
+
self.assertEqual(uri.global_phone_number, None)
|
|
22
|
+
self.assertEqual(str(uri), "sip:atlanta.com")
|
|
23
|
+
|
|
24
|
+
def test_host_and_parameter_without_value(self) -> None:
|
|
25
|
+
uri = URI.parse("sip:1.2.3.4;lr")
|
|
26
|
+
|
|
27
|
+
self.assertEqual(uri.host, "1.2.3.4")
|
|
28
|
+
self.assertEqual(uri.port, None)
|
|
29
|
+
self.assertEqual(uri.user, None)
|
|
30
|
+
self.assertEqual(uri.password, None)
|
|
31
|
+
self.assertEqual(
|
|
32
|
+
uri.parameters,
|
|
33
|
+
{"lr": None},
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
self.assertEqual(uri.global_phone_number, None)
|
|
37
|
+
self.assertEqual(str(uri), "sip:1.2.3.4;lr")
|
|
38
|
+
|
|
39
|
+
def test_user_and_host(self) -> None:
|
|
40
|
+
uri = URI.parse("sip:alice@atlanta.com")
|
|
41
|
+
|
|
42
|
+
self.assertEqual(uri.host, "atlanta.com")
|
|
43
|
+
self.assertEqual(uri.port, None)
|
|
44
|
+
self.assertEqual(uri.user, "alice")
|
|
45
|
+
self.assertEqual(uri.password, None)
|
|
46
|
+
self.assertEqual(uri.parameters, {})
|
|
47
|
+
|
|
48
|
+
self.assertEqual(uri.global_phone_number, None)
|
|
49
|
+
self.assertEqual(str(uri), "sip:alice@atlanta.com")
|
|
50
|
+
|
|
51
|
+
def test_user_and_host_and_parameters(self) -> None:
|
|
52
|
+
uri = URI.parse("sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15")
|
|
53
|
+
|
|
54
|
+
self.assertEqual(uri.host, "atlanta.com")
|
|
55
|
+
self.assertEqual(uri.port, None)
|
|
56
|
+
self.assertEqual(uri.user, "alice")
|
|
57
|
+
self.assertEqual(uri.password, None)
|
|
58
|
+
self.assertEqual(
|
|
59
|
+
uri.parameters,
|
|
60
|
+
{
|
|
61
|
+
"maddr": "239.255.255.1",
|
|
62
|
+
"ttl": "15",
|
|
63
|
+
},
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
self.assertEqual(uri.global_phone_number, None)
|
|
67
|
+
self.assertEqual(str(uri), "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15")
|
|
68
|
+
|
|
69
|
+
def test_phone_identity(self) -> None:
|
|
70
|
+
uri = URI.parse("sip:+123456789@1.2.3.4")
|
|
71
|
+
|
|
72
|
+
self.assertEqual(uri.host, "1.2.3.4")
|
|
73
|
+
self.assertEqual(uri.port, None)
|
|
74
|
+
self.assertEqual(uri.user, "+123456789")
|
|
75
|
+
self.assertEqual(uri.password, None)
|
|
76
|
+
self.assertEqual(uri.parameters, {})
|
|
77
|
+
|
|
78
|
+
self.assertEqual(uri.global_phone_number, "+123456789")
|
|
79
|
+
self.assertEqual(str(uri), "sip:+123456789@1.2.3.4")
|
|
80
|
+
|
|
81
|
+
def test_full(self) -> None:
|
|
82
|
+
uri = URI.parse("sip:alice:secret@atlanta.com:5060;maddr=239.255.255.1;ttl=15")
|
|
83
|
+
|
|
84
|
+
self.assertEqual(uri.host, "atlanta.com")
|
|
85
|
+
self.assertEqual(uri.port, 5060)
|
|
86
|
+
self.assertEqual(uri.user, "alice")
|
|
87
|
+
self.assertEqual(uri.password, "secret")
|
|
88
|
+
self.assertEqual(
|
|
89
|
+
uri.parameters,
|
|
90
|
+
{
|
|
91
|
+
"maddr": "239.255.255.1",
|
|
92
|
+
"ttl": "15",
|
|
93
|
+
},
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
self.assertEqual(uri.global_phone_number, None)
|
|
97
|
+
self.assertEqual(
|
|
98
|
+
str(uri), "sip:alice:secret@atlanta.com:5060;maddr=239.255.255.1;ttl=15"
|
|
99
|
+
)
|