Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
7abf3797
Commit
7abf3797
authored
Jan 16, 2016
by
Daniel W Bond
Browse files
added test cases to verify __contains__ implementation
parent
e9a7b292
Changes
1
Hide whitespace changes
Inline
Side-by-side
roomlist/housing/test_models.py
0 → 100644
View file @
7abf3797
# standard library imports
from
__future__
import
absolute_import
,
print_function
# core django imports
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
# imports from your apps
from
accounts.models
import
Student
from
housing.models
import
Building
,
Floor
,
Room
class
BuildingTest
(
TestCase
):
def
setUp
(
self
):
global
wilson
global
wilson_third
global
wilson_313
wilson
=
Building
.
objects
.
create
(
name
=
'Wilson'
,
neighbourhood
=
'sh'
,
campus
=
'ff'
)
wilson_third
=
Floor
.
objects
.
create
(
building
=
wilson
,
number
=
3
)
wilson_313
=
Room
.
objects
.
create
(
floor
=
wilson_third
,
number
=
313
)
wilson
.
save
()
wilson_third
.
save
()
wilson_313
.
save
()
gmason
=
User
.
objects
.
create_user
(
username
=
'gmason'
,
first_name
=
'George'
,
last_name
=
'Mason'
,
email
=
'gmason@masonlive.gmu.edu'
,
password
=
'eagle_bank'
)
global
george
george
=
Student
.
objects
.
create
(
user
=
gmason
,
room
=
wilson_313
)
george
.
save
()
def
test_building_contains_room
(
self
):
self
.
assertTrue
(
wilson_313
in
wilson
)
def
test_building_contains_floor
(
self
):
self
.
assertTrue
(
wilson_third
in
wilson
)
def
test_building_contains_student
(
self
):
self
.
assertTrue
(
george
in
wilson
)
class
FloorTest
(
TestCase
):
def
test_floor_contains_room
(
self
):
self
.
assertTrue
(
wilson_313
in
wilson_third
)
def
test_floor_contains_student
(
self
):
self
.
assertTrue
(
george
in
wilson_third
)
class
RoomTest
(
TestCase
):
def
test_room_contains_student
(
self
):
self
.
assertTrue
(
george
in
wilson_313
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment