Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UWEFlix-Combined
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rj2-ingham
UWEFlix-Combined
Commits
593effa9
Commit
593effa9
authored
1 year ago
by
Georgio Costa
Browse files
Options
Downloads
Patches
Plain Diff
Updated cinema unit tests
parent
441c5d93
Branches
Branches containing commit
No related tags found
1 merge request
!34
Tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cinema/tests.py
+30
-22
30 additions, 22 deletions
cinema/tests.py
with
30 additions
and
22 deletions
cinema/tests.py
+
30
−
22
View file @
593effa9
...
...
@@ -20,7 +20,7 @@ class AddCinemaTests(TestCase):
screen
=
Screen
.
objects
.
create
(
cinema
=
cinema
,
screen_number
=
1
,
seating_capacity
=
100
)
film
=
Film
.
objects
.
create
(
title
=
"
Film1
"
,
length
=
datetime
.
timedelta
(
hours
=
2
),
rating
=
12
,
genre
=
"
Comedy
"
,
poster_url
=
"
www.example.com/image.webp
"
)
tz
=
timezone
.
get_current_timezone
()
showing
=
Showing
.
objects
.
create
(
screen
=
screen
,
film
=
film
,
start_time
=
datetime
.
datetime
(
2023
,
1
,
1
,
11
,
30
,
0
,
tzinfo
=
tz
),
end_time
=
datetime
.
datetime
(
2023
,
1
,
1
,
13
,
30
,
0
,
tzinfo
=
tz
),
available_seats
=
200
)
showing
=
Showing
.
objects
.
create
(
screen
=
screen
,
film
=
film
,
start_time
=
datetime
.
datetime
(
2023
,
1
2
,
1
,
1
1
,
30
,
0
,
tzinfo
=
tz
),
available_seats
=
200
)
# Test: add a new film
# Expected result: new film object added to the system
...
...
@@ -74,30 +74,38 @@ class AddCinemaTests(TestCase):
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
len
(
Screen
.
objects
.
filter
()),
0
)
# ERROR: doesn't update details but redirects to manage_screens which implies it was successful
# check is update_showing even works
# Test: update an existing showing
# Expected result: showing's time is changed
# def testShowingUpdated(self):
# form = ShowingForm(data={'screen':Screen.objects.Get(screen_number=1), 'film':Film.objects.Get(name="Film1"), 'start_time':datetime.time(12, 45, 0)})
# pk = 1
# response = self.client.post("/manage_screens/showings/update_showing/" + pk + "/", form=form)
# self.assertEqual(response.status_code, HTTPStatus.FOUND)
# self.assertEqual(Showing.objects.get(id=1).start_time, datetime.time(12, 45, 0))
# self.client.login(username="test", password="test")
# tz = timezone.get_current_timezone()
# newtime = datetime.datetime(2023, 12, 1, 12, 45, 0, tzinfo=tz)
# response = self.client.post(reverse('update_showing', args=[1]), {'screen':Screen.objects.get(screen_number=1).id, 'film':Film.objects.get(title="Film1").id, 'start_time':"0023-04-24 16:44:00", 'social_distancing': False})
# self.assertEqual(response.status_code, 302)
# print(response)
# self.assertEqual(Showing.objects.get(id=1).start_time, newtime)
# #Can't be tested with current film/screening issues
# def testShowingDeleted(self):
# s = Showing.objects.create(screen=Screen.objects.get(screen_number=2), film=Film.objects.get(title="Film1"), start_time=datetime.time(20,00,00))
# pk = str(s.id)
# response = self.client.post("/manage_screens/showings/delete_showing/" + pk)
# self.assertEqual(Screen.objects.get(id=int(pk)), None)
# Test: delete a showing
# Expected result: showing no longer exists
def
testShowingDeleted
(
self
):
self
.
assertEqual
(
len
(
Showing
.
objects
.
filter
()),
1
)
response
=
self
.
client
.
post
(
reverse
(
'
delete_showing
'
,
args
=
[
1
]))
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
len
(
Showing
.
objects
.
filter
()),
0
)
# #ERROR: RelatedManager object has no attribute 'is_authenticated'
# def testFilmDeleted(self):
# f = Film.objects.create(title="Film2", length=datetime.timedelta(hours=1), rating=12, genre="Action", poster_url="www.test.com/image.png")
# pk = str(f.id)
# response = self.client.post("/delete_film/" + pk)
# self.assertEqual(Film.objects.get(id=int(pk)), None)
# Test: delete a film
# Expected result: film no longer exists
def
testFilmDeleted
(
self
):
self
.
assertEqual
(
len
(
Film
.
objects
.
filter
()),
1
)
response
=
self
.
client
.
post
(
reverse
(
'
delete_film
'
,
args
=
[
1
]))
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
len
(
Film
.
objects
.
filter
()),
0
)
# #Can't test until film works
# def testFilmShowings(self):
# response = self.client.get("/showings/1")
# print(response.context)
\ No newline at end of file
# Test: view the list of showings for a film
# Expected result: one showing object found
def
testFilmShowings
(
self
):
response
=
self
.
client
.
post
(
reverse
(
'
film_showings
'
,
args
=
[
1
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
len
(
response
.
context
[
'
showings
'
]),
1
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment