This repository was archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71aeb00
commit 3c58ea2
Showing
1 changed file
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,66 @@ | ||
from __future__ import print_function | ||
|
||
import os | ||
import mock | ||
import pytest | ||
import time | ||
|
||
import pushbullet | ||
from pushbullet import device | ||
|
||
API_KEY = os.environ["PUSHBULLET_API_KEY"] | ||
|
||
class TestDevices(object): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
cls.pb = pushbullet.PushBullet(API_KEY) | ||
cls.device_iden = "test_iden" | ||
device_info = {"active": True, "iden": cls.device_iden, "created": time.time(), "modified": time.time(), | ||
"type": "stream", "kind": "stream", "nickname": "test dev", "manufacturer": "test c", "model": "test m", "pushable": True} | ||
cls.account = mock.Mock(return_value=True) | ||
cls.device = device.Device(cls.account, device_info) | ||
|
||
def test_encoding_support(self): | ||
for device in self.pb.devices: | ||
# We're not actually intersted in the output, just that it doesn't | ||
# cause any errors. | ||
print(device) | ||
# We're not actually intersted in the output, just that it doesn't | ||
# cause any errors. | ||
print(self.device) | ||
|
||
def test_push_note(self): | ||
title = "test title" | ||
body = "test body" | ||
self.device.push_note(title, body) | ||
pushed_data = {"type": "note", "title": title, "body": body, "device_iden": self.device_iden} | ||
self.account._push.assert_called_with(pushed_data) | ||
|
||
def test_push_address(self): | ||
name = "test name" | ||
address = "test address" | ||
self.device.push_address(name, address) | ||
pushed_data = {"type": "address", "name": name, "address": address, "device_iden": self.device_iden} | ||
self.account._push.assert_called_with(pushed_data) | ||
|
||
def test_push_list(self): | ||
title = "test title" | ||
items = ["test item 1", "test item 2"] | ||
self.device.push_list(title, items) | ||
pushed_data = {"type": "list", "title": title, "items": items, "device_iden": self.device_iden} | ||
self.account._push.assert_called_with(pushed_data) | ||
|
||
def test_push_link(self): | ||
title = "test title" | ||
url = "http://test.url" | ||
body = "test body" | ||
self.device.push_link(title, url, body) | ||
pushed_data = {"type": "link", "title": title, "url": url, "body": body, "device_iden": self.device_iden} | ||
self.account._push.assert_called_with(pushed_data) | ||
|
||
def test_push_file(self): | ||
file_name = "test_file.name" | ||
file_url = "http://file.url" | ||
file_type = "test/type" | ||
body = "test body" | ||
self.device.push_file(file_name, file_url, file_type, body) | ||
self.account.push_file.assert_called_with(file_name, file_url, file_type, body, device=self.device) | ||
|
||
def test_account_push(self): | ||
data = {"title": "test title"} | ||
self.device._push(data) | ||
pushed_data = {"title": "test title", "device_iden": self.device_iden} | ||
self.account._push.assert_called_with(pushed_data) |