Skip to content

Commit

Permalink
basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brysontyrrell committed May 14, 2017
1 parent 265e1b6 commit 266deff
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -11,7 +11,7 @@
long_description = fobj.read()

setup(
name='Jook',
name='jook',
version=version,
description='A Jamf Pro webhook simulator',
long_description=long_description,
Expand Down
Empty file added tests/__init__.py
Empty file.
40 changes: 40 additions & 0 deletions tests/test_jook.py
@@ -0,0 +1,40 @@
import json
import xml.etree.ElementTree as Et

import pytest
import responses

import jook
from jook.exceptions import InvalidEvent, InvalidURL


def test_url_scheme_required():
with pytest.raises(InvalidURL):
jook.Computer('localhost', 'ComputerAdded')


def test_valid_events():
for event in jook.Computer.valid_events:
jook.Computer('http://localhost', event)

with pytest.raises(InvalidEvent):
jook.Computer('http://localhost', 'SomeEvent')


def test_static_data():
comp = jook.Computer('http://localhost', 'ComputerAdded')
assert comp._data is not None
assert comp.get_data() == comp.get_data()


def test_random_data():
comp = jook.Computer('http://localhost', 'ComputerAdded', randomize=True)
assert comp._data is None
assert comp.get_data() != comp.get_data()


def test_mode():
comp = jook.Computer('http://localhost', 'ComputerAdded')
json.loads(comp.to_json())
Et.fromstring(comp.to_xml())

0 comments on commit 266deff

Please sign in to comment.