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
265e1b6
commit 266deff
Showing
3 changed files
with
41 additions
and
1 deletion.
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
Empty file.
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 |
---|---|---|
@@ -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()) | ||
|