def test_user_name(self, fix_registered): "Test get name attribute of User object for connected user." from relayr import Client token = fix_registered.testset1['token'] c = Client(token=token) usr = c.get_user() assert usr.name == fix_registered.testset1['userName']
def test_get_user_bookmarked_devices(self, fix_registered): "Test get user's bookmarked devices." from relayr import Client token = fix_registered.testset1['token'] c = Client(token=token) user = c.get_user() b_devs = user.get_bookmarked_devices() assert type(list(b_devs)) == list
def test_get_wunderbar_devices(self, fix_registered): "Test get user's registered wunderbar devices and master." from relayr import Client token = fix_registered.testset1['token'] c = Client(token=token) usr = c.get_user() items = list(usr.register_wunderbar()) assert len(items) == 7
def _x_user_parser(user, data): client = Client(token=user.credentials.token) usr = client.get_user() user.name = usr.name user.id = usr.id user.email = usr.email user.transmitters = list(usr.get_transmitters()) user.transmitters_devices = {} for t in user.transmitters: user.transmitters_devices[t.name] = client.api.get_transmitter_devices(t.id) return user
def test_find_wunderbar_devices(self, fix_registered): "Test get all devices on a Wunderbar." from relayr import Client from relayr.resources import Device, Transmitter token = fix_registered.testset1['token'] c = Client(token=token) usr = c.get_user() assert usr.name == fix_registered.testset1['userName'] devs = usr.register_wunderbar() for d in devs: assert d.__class__ in (Device, Transmitter) assert hasattr(d, 'id')
def test_users_resources(self, fix_registered): "Test get user's resources." from relayr import Client from relayr.resources import User, Publisher, App, Device token = fix_registered.testset1['token'] c = Client(token=token) usr = c.get_user() assert usr.__class__ == User assert c.get_app().__class__ == App assert next(usr.get_apps()).__class__ == App assert next(usr.get_devices()).__class__ == Device assert next(usr.get_publishers()).__class__ == Publisher
def _x_user_parser(user, data): client = Client(token=user.credentials.token) usr = client.get_user() user.name = usr.name user.id = usr.id user.email = usr.email user.transmitters = list(usr.get_transmitters()) user.transmitters_devices = {} for t in user.transmitters: user.transmitters_devices[ t.name] = client.api.get_transmitter_devices(t.id) return user
def test_find_wunderbar_devices(self, fix_registered): "Test get all devices on a Wunderbar." from relayr import Client from relayr.resources import Device, Transmitter token = fix_registered.testset1['token'] c = Client(token=token) usr = c.get_user() assert usr.name == fix_registered.testset1['userName'] devs = list(usr.register_wunderbar()) for d in devs: assert d.__class__ in (Device, Transmitter) assert hasattr(d, 'id') # now clean-up for dev in [d for d in devs if d.__class__ == Device]: dev.delete() for t in [d for d in devs if d.__class__ == Transmitter]: t.delete()
def test_read_pubnub_device_10s(self, fix_registered): "Test connect to a device via PubNub and read data for some time." import time from relayr import Client from relayr.resources import Device token = fix_registered.testset1['token'] deviceID = fix_registered.testset1['deviceID'] self.received_data = [] c = Client(token=token) dev = Device(id=deviceID, client=c).get_info() usr = c.get_user() app = c.get_app() conn = usr.connect_device(app, dev, self.receive) conn.start() time.sleep(10) conn.stop() assert len(self.received_data) > 0 for item in self.received_data: assert 'ts' in item
def test_post_user_devices_bookmarks(self, fix_registered): "Test get user's bookmarked devices." from relayr import Client token = fix_registered.testset1['token'] c = Client(token=token) user = c.get_user()
def test4(self, fix_registered): "Test get publishers for connected user." from relayr import Client token = fix_registered.testset1['token'] c = Client(token=token) usr = c.get_user()