-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlaundry_test.py
More file actions
42 lines (36 loc) · 1.33 KB
/
laundry_test.py
File metadata and controls
42 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import mock
from nose.tools import ok_
from penn import Laundry
class TestLaundry():
def setUp(self):
self.laundry = Laundry()
def fakeLaundryGet(url, *args, **kwargs):
if "suds.kite.upenn.edu" in url:
with open("tests/laundry_snapshot.html", "rb") as f:
m = mock.MagicMock(content=f.read())
return m
else:
raise NotImplementedError
@mock.patch("requests.get", fakeLaundryGet)
def test_all(self):
data = self.laundry.all_status()
ok_(len(data) > 50)
ok_('Class of 1925' in data)
# Check all halls have appropriate data points
for i, hall in data.items():
for t in ['washers', 'dryers']:
ok_("running" in hall[t])
ok_("open" in hall[t])
@mock.patch("requests.get", fakeLaundryGet)
def test_single_hall(self):
for i in range(3):
data = self.laundry.hall_status(i)
machines = data['machines']
# Check for general hall information
ok_('washers' in machines)
ok_('dryers' in machines)
# Check all machines have appropriate data points
for machine in machines["details"]:
ok_('id' in machine)
ok_('type' in machine)
ok_('status' in machine)