Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
channels test
Browse files Browse the repository at this point in the history
added channels test
minor modification in device tests
  • Loading branch information
kovacsbalu committed Jan 14, 2015
1 parent 3c58ea2 commit 3fac367
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 11 deletions.
61 changes: 53 additions & 8 deletions tests/test_channels.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,64 @@
from __future__ import print_function

import os
import mock
import time

import pushbullet
from pushbullet import channel

API_KEY = os.environ["PUSHBULLET_API_KEY"]

class TestChannels(object):

@classmethod
def setup_class(cls):
cls.pb = pushbullet.PushBullet(API_KEY)
cls.channel_tag = "test_tag"
channel_info = {'iden': "test_iden", 'name': 'test channel', 'created': time.time(), 'modified': time.time(), 'tag': cls.channel_tag, 'active': True}
cls.account = mock.Mock(return_value=True)
cls.channel = channel.Channel(cls.account, channel_info)

def test_encoding_support(self):
for channel in self.pb.channels:
# We're not actually intersted in the output, just that it doesn't
# cause any errors.
print(channel)
# We're not actually intersted in the output, just that it doesn't
# cause any errors.
print(self.channel)

def test_push_note(self):
title = "test title"
body = "test body"
self.channel.push_note(title, body)
pushed_data = {"type": "note", "title": title, "body": body, "channel_tag": self.channel_tag}
self.account._push.assert_called_with(pushed_data)

def test_push_address(self):
name = "test name"
address = "test address"
self.channel.push_address(name, address)
pushed_data = {"type": "address", "name": name, "address": address, "channel_tag": self.channel_tag}
self.account._push.assert_called_with(pushed_data)

def test_push_list(self):
title = "test title"
items = ["test item 1", "test item 2"]
self.channel.push_list(title, items)
pushed_data = {"type": "list", "title": title, "items": items, "channel_tag": self.channel_tag}
self.account._push.assert_called_with(pushed_data)

def test_push_link(self):
title = "test title"
url = "http://test.url"
body = "test body"
self.channel.push_link(title, url, body)
pushed_data = {"type": "link", "title": title, "url": url, "body": body, "channel_tag": self.channel_tag}
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.channel.push_file(file_name, file_url, file_type, body)
self.account.push_file.assert_called_with(file_name, file_url, file_type, body, channel=self.channel)

def test_push(self):
data = {"title": "test title"}
self.channel._push(data)
pushed_data = {"title": "test title", "channel_tag": self.channel_tag}
self.account._push.assert_called_with(pushed_data)
4 changes: 1 addition & 3 deletions tests/test_devices.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import print_function

import os
import mock
import pytest
import time

from pushbullet import device
Expand Down Expand Up @@ -59,7 +57,7 @@ def test_push_file(self):
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):
def test_push(self):
data = {"title": "test title"}
self.device._push(data)
pushed_data = {"title": "test title", "device_iden": self.device_iden}
Expand Down

0 comments on commit 3fac367

Please sign in to comment.