-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from pennlabs/studyspaces
Add booking endpoint for studyspaces
- Loading branch information
Showing
10 changed files
with
168 additions
and
23 deletions.
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
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = '1.6.7' | ||
__version__ = '1.6.8' | ||
|
||
from .registrar import Registrar | ||
from .directory import Directory | ||
|
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
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
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
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
beautifulsoup4==4.6.0 | ||
html5lib==0.999 | ||
html5lib==1.0.1 | ||
mock==2.0.0 | ||
nameparser==0.4.0 | ||
nameparser==0.5.6 | ||
nose==1.3.7 | ||
pytz==2017.3 | ||
requests==2.4.3 | ||
requests==2.18.4 | ||
six==1.11.0 |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
url='https://github.com/pennlabs/penn-sdk-python', | ||
author='Penn Labs', | ||
author_email='[email protected]', | ||
version='1.6.7', | ||
version='1.6.8', | ||
packages=['penn'], | ||
license='MIT', | ||
package_data={ | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import datetime | ||
import pytz | ||
|
||
from nose.tools import ok_ | ||
from penn import StudySpaces | ||
|
@@ -13,12 +12,55 @@ def setUp(self): | |
def test_buildings(self): | ||
buildings = self.studyspaces.get_buildings() | ||
ok_(len(buildings) > 0) | ||
for building in buildings: | ||
ok_(building["id"] > 0) | ||
ok_(building["name"]) | ||
ok_(building["service"]) | ||
|
||
def test_room_name_mapping(self): | ||
mapping = self.studyspaces.get_room_id_name_mapping(2683) | ||
ok_(len(mapping) > 0) | ||
|
||
def test_rooms(self): | ||
now = pytz.timezone("US/Eastern").localize(datetime.datetime.now()) | ||
rooms = self.studyspaces.get_rooms(2683, now, now + datetime.timedelta(days=3)) | ||
ok_(len(rooms) > 0) | ||
""" Make sure that at least 3 buildings have at least one room. """ | ||
|
||
now = datetime.datetime.now() | ||
buildings = self.studyspaces.get_buildings() | ||
for building in buildings[:3]: | ||
rooms = self.studyspaces.get_rooms(building["id"], now, now + datetime.timedelta(days=3)) | ||
ok_(len(rooms) > 0, "The building {} does not have any rooms!".format(building)) | ||
for room in rooms: | ||
ok_(room["room_id"] > 0) | ||
ok_(len(room["times"]) > 0) | ||
|
||
def test_booking(self): | ||
""" Test the checks before booking the room, but don't actually book a room. """ | ||
|
||
buildings = self.studyspaces.get_buildings() | ||
# get the first building | ||
building_id = buildings[0]["id"] | ||
|
||
now = datetime.datetime.now() | ||
rooms = self.studyspaces.get_rooms(building_id, now, now + datetime.timedelta(days=1)) | ||
|
||
if not rooms: | ||
return | ||
|
||
# get the first room | ||
room_id = rooms[0]["room_id"] | ||
room_time = rooms[0]["times"][0] | ||
|
||
result = self.studyspaces.book_room( | ||
building_id, | ||
room_id, | ||
datetime.datetime.strptime(room_time["start"][:-6], "%Y-%m-%dT%H:%M:%S"), | ||
datetime.datetime.strptime(room_time["end"][:-6], "%Y-%m-%dT%H:%M:%S"), | ||
"John", | ||
"Doe", | ||
"[email protected]", | ||
"Test Meeting", | ||
"000-000-0000", | ||
"2-3", | ||
fake=True | ||
) | ||
ok_(result) |