Example #1
0
 def setUp(self):
     """
     TODO
     """
     res = ResourceTest()
     server = Endpoint()
     server.addResource(res)
Example #2
0
 def setUp(self):
     """
     TODO
     """
     server = Endpoint()
     res = ImageResource()
     server.register(res)
Example #3
0
 def setUp(self):
     """
     Setting up a CoAP server running on localhost for testing.
     """
     server = Endpoint()
     server.discoveryResource()
     server.run()
Example #4
0
    def setUp(self):
        """
        Setup a CoAP server and assign a TimeResource to it
        """
        self.server = Endpoint(__name__)

        class TimeResource(Resource):
            """
            Simple Time Resource that give the time and support observation.

            :return:
            """
            def __call__(self):
                """
                Resource that returns the current time on a GET request.
                It also Supports observing.
                """
                self.time = datetime.datetime.now()
                self.changed()  # Call changed to notify subscribers
                return self.time

        self.server.add_url_rule("/time",
                                 obs=True,
                                 methods=["GET", "POST"],
                                 resource=TimeResource(title="CurrentTime"))
Example #5
0
 def setUp(self):
     """
     Set up a configuration as specified in CoAP_CFG_01
     """
     server = Endpoint()
     res = Observe()
     server.addResource(res)
Example #6
0
    def setUp(self):
        """
        Setup a simple server with an hello world resource.

        Defines a resource that returns text with special characters on GET.
        """
        self.server = Endpoint(__name__)

        @self.server.route("/hello",
            title="Hello-World Resource",
            rt="HelloWorld")
        def hello():
            return self.message
Example #7
0
    def setUp(self):
        """
        Set up a loop to fetch the weather.
        :return:
        """
        self.server = Endpoint(__name__)

        def weather(self):
            """
            Infinite loop checking weather on a exterior website
            """
            while True:
                r = urlopen("http://openweather.com/")
                publish(content=r.readall())

        self.server.add_url_rule("/weather",
                                 function=weather,
                                 observable=True,
                                 t=["json", "text"],
                                 title="GET the current weather in Paris")
Example #8
0
    def setUp(self):
        """
        Set up of a careless server for request testing
        """
        self.server = Endpoint(__name__)

        def careless(self, request):
            """
            This implements a 'separate' resource for demonstration purposes.
            Defines a resource that returns a response in a separate CoAP
            Message

            1 °) promise the client that this request will be acted upon
            by sending an Acknowledgement...

            :param request:
            """
            request.accept()  # ... and then do nothing. Pretty mean.

        self.server.route("careless",
                          title="This resource will ACK anything, "
                          "but never send a separate response",
                          resourceType="SeparateResponseTester",
                          function=careless)
Example #9
0
- Resources used in TD_COAP_CORE tests should not exceed 64 bytes
- Large resources used in TD_COAP_BLOCK tests shall not exceed 2048 bytes
- TD_COAP_LINK tests may require usage of Block options with some implementations
"""
import datetime
from threading import Timer
import unittest
from pycolo import codes
from pycolo.codes import mediaCodes
from pycolo.endpoint import Endpoint
from pycolo.message import Response
from pycolo.request import request
from pycolo.resource import Resource

server = Endpoint("PlugTestServer", PLUGTEST_BLOCK_SIZE=64)

@server.add("/large",
    rt="BlockWiseTransferTester",
    methods=["GET"],
    title="This is a large resource (>1024 bytes) for testing block-wise transfer.")
def large():
    """
    This class implements a resource that returns a larger amount of
    data on GET requests in order to test blockwise transfers.

    Large resources used in TD_COAP_BLOCK tests shall not exceed 2048 bytes

    This resource implements a test of specification for the ETSI IoT CoAP
    Plugtests.
Example #10
0
 def setUp(self):
     """
     Set up a basic endpoint for CoAP message exchange
     """
     self.server = Endpoint(__name__)
Example #11
0
 def setUp(self):
     """
     Set up a simple Endpoint. All the settings will be done
     in the further tests.
     """
     self.server = Endpoint(__name__)