gadgets / gadgets / tests /

import os, time, random, threading
from import eq_
from import GPIO
from gadgets.pins.beaglebone import pins
from gadgets import Addresses, Sockets, Gadgets
from gadgets.devices.input.factory import input_factory
from gadgets.devices.input.adc import ADCPoller

def setup():
    ADCPoller.InputClass = FakeADC

class FakeADC(threading.Thread):

    def __init__(self, target, pin, threshold=2048, sleep_time=1, delay=None):
        self._target = target
        super(FakeADC, self).__init__()

    def value(self):
        return False

    def run(self):

    def close(self):

class TestInputACD(object):

    def setup(self):
        port = random.randint(5000, 50000)
        self.addresses = Addresses(in_port=port, out_port=port+1, req_port=port+2)
        pin = None
        self.sockets = Sockets(self.addresses, events=['update'])
        self.input = input_factory('left', 'input', {'pin':None, 'input_type': 'adc'}, self.addresses)
        self.gadgets = Gadgets([self.input], self.addresses)

    def test_create(self):

    def test_run(self):
        t = threading.Thread(target=self.gadgets.start)
        event, message = self.sockets.recv()
        eq_(event, 'update')
        expected = {u'left': {u'input': {u'input': {u'value': 2046}}}}
        eq_(message, expected)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.