class TestLaundry(): def setUp(self): self.laundry = Laundry() def test_all(self): data = self.laundry.all_status() ok_(len(data) > 50) eq_('Class of 1925 House', data[0]['name']) # Check all halls have appropriate data points for i, hall in enumerate(data): # Not a valid check anymore because of New College House # eq_(hall['hall_no'], i) ok_(hall['dryers_available'] >= 0) ok_(hall['dryers_in_use'] >= 0) ok_(hall['washers_available'] >= 0) ok_(hall['washers_in_use'] >= 0) def test_single_hall(self): for i in range(1): data = self.laundry.hall_status(i) machines = data['machines'] # Check all machines have appropriate data points for i, machine in enumerate(machines): eq_(machine['number'], str(i + 1)) ok_('available' in machine) ok_('machine_type' in machine) ok_('time_left' in machine) def test_usage(self): for i in range(10): data = self.laundry.machine_usage(i) for j in data: ok_(j in self.laundry.days) for k in data[j]: ok_(k in self.laundry.busy_dict.values())
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)
def setUp(self): self.laundry = Laundry()
from penn import Transit, Directory, Dining, DiningV2, Registrar, Map, Laundry, StudySpaces, Calendar, Fitness, Wharton from os import getenv din = Dining(getenv("DIN_USERNAME"), getenv("DIN_PASSWORD")) dinV2 = DiningV2(getenv("DIN_USERNAME"), getenv("DIN_PASSWORD")) reg = Registrar(getenv("REG_USERNAME"), getenv("REG_PASSWORD")) penn_dir = Directory(getenv("DIR_USERNAME"), getenv("DIR_PASSWORD")) map_search = Map(getenv("NEM_USERNAME"), getenv("NEM_PASSWORD")) transit = Transit(getenv("TRANSIT_USERNAME"), getenv("TRANSIT_PASSWORD")) laundry = Laundry() studyspaces = StudySpaces(getenv("LIBCAL_ID"), getenv("LIBCAL_SECRET")) wharton = Wharton() fitness = Fitness(getenv("FITNESS_TOKEN")) calendar = Calendar() wharton = Wharton() depts = { "AAMW": "Art & Arch of Med. World", "ACCT": "Accounting", "AFRC": "Africana Studies", "AFST": "African Studies Program", "ALAN": "Asian Languages", "AMCS": "Applied Math & Computatnl Sci.", "ANAT": "Anatomy", "ANCH": "Ancient History", "ANEL": "Ancient Near East Languages", "ANTH": "Anthropology", "ARAB": "Arabic", "ARCH": "Architecture", "ARTH": "Art History", "ASAM": "Asian American Studies", "ASTR": "Astronomy",