Skip to content

Commit b524108

Browse files
committed
Delint and fix broken tests
1 parent 9ba6247 commit b524108

17 files changed

Lines changed: 51 additions & 87 deletions

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
git fetch origin master "${{ github.event.pull_request.base.sha }}"
2424
git diff --diff-filter=ACM --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" > "${HOME}/changed_files.txt"
2525
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v3
26+
uses: actions/setup-python@v2
2727
with:
2828
python-version: ${{ matrix.python-version }}
2929
- name: Install dependencies

classroom/snippets/classroom_create_course.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
limitations under the License.
1515
1616
"""
17-
# [START classroom_create_course]
1817

18+
# [START classroom_create_course]
1919
from __future__ import print_function
2020

2121
import google.auth

classroom/snippets/classroom_create_coursework.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
limitations under the License.
1515
1616
"""
17+
# [START classroom_create_coursework]
1718
from __future__ import print_function
1819

1920
import google.auth
2021
from googleapiclient.discovery import build
2122
from googleapiclient.errors import HttpError
2223

23-
# [START classroom_create_coursework]
24-
2524

2625
def classroom_create_coursework(course_id):
2726

classroom/snippets/classroom_get_course.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"""
1717

1818
# [START classroom_get_course]
19-
2019
from __future__ import print_function
2120

2221
import google.auth

classroom/snippets/classroom_list_courses.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ def classroom_list_courses():
3434
"""
3535

3636
creds, _ = google.auth.default()
37-
# pylint: disable=maybe-no-member
38-
course = None
3937
try:
4038
service = build('classroom', 'v1', credentials=creds)
4139
courses = []
4240
page_token = None
4341

4442
while True:
43+
# pylint: disable=maybe-no-member
4544
response = service.courses().list(pageToken=page_token,
4645
pageSize=100).execute()
4746
courses.extend(response.get('courses', []))
@@ -55,7 +54,7 @@ def classroom_list_courses():
5554
print("Courses:")
5655
for course in courses:
5756
print(f"{course.get('name'), course.get('id')}")
58-
return course
57+
return courses
5958
except HttpError as error:
6059
print(f"An error occurred: {error}")
6160
return error

classroom/snippets/classroom_list_student_submissions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
limitations under the License.
1515
1616
"""
17+
# [START classroom_list_student_submissions]
1718
from __future__ import print_function
1819

1920
import google.auth
2021
from googleapiclient.discovery import build
2122
from googleapiclient.errors import HttpError
2223

23-
# [START classroom_list_student_submissions]
24-
2524

2625
def classroom_list_student_submissions(course_id, coursework_id, user_id):
2726
"""

classroom/snippets/classroom_list_submissions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
limitations under the License.
1515
1616
"""
17+
# [START classroom_list_submissions]
1718
from __future__ import print_function
1819

1920
import google.auth
2021
from googleapiclient.discovery import build
2122
from googleapiclient.errors import HttpError
2223

23-
# [START classroom_list_submissions]
24-
2524

2625
def classroom_list_submissions(course_id, coursework_id):
2726
"""

classroom/snippets/classroom_patch_course.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"""
1515

1616
# [START classroom_patch_course]
17-
1817
from __future__ import print_function
1918

2019
import google.auth
@@ -44,7 +43,7 @@ def classroom_patch_course(course_id):
4443
updateMask='section,room',
4544
body=course).execute()
4645
print(f" Course updated are: {course.get('name')}")
47-
46+
return course
4847
except HttpError as error:
4948
print(f"An error occurred: {error}")
5049

classroom/snippets/classroom_update_course.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""
1616

1717
# [START classroom_update_course]
18-
1918
from __future__ import print_function
2019

2120
import google.auth
@@ -44,6 +43,7 @@ def classroom_update_course(course_id):
4443
course['room'] = '410'
4544
course = service.courses().update(id=course_id, body=course).execute()
4645
print(f" Updated Course is: {course.get('name')}")
46+
return course
4747

4848
except HttpError as error:
4949
print(f"An error occurred: {error}")

classroom/snippets/test_classroom_create_course.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
import unittest
1515

1616
import classroom_create_course
17+
from base_test import BaseTest
1718

1819

19-
class TestClassroomCreateCourse(unittest.TestCase):
20+
class TestClassroomCreateCourse(BaseTest):
2021
"""Unit test class for Create course snippet"""
21-
@classmethod
22-
def test_classroom_create_course(cls):
22+
def test_classroom_create_course(self):
2323
"""Class function for Create course snippet"""
2424
course = classroom_create_course.classroom_create_course()
25-
cls.assertIsNotNone(cls, course)
26-
cls.doClassCleanups()
25+
self.assertIsNotNone(course)
26+
self.delete_course_on_cleanup(course.get('id'))
2727

2828

2929
if __name__ == "__main__":

0 commit comments

Comments
 (0)