diff --git a/Scripts/API_Tests/add_course_to_group_from_csv.py b/Scripts/API_Tests/add_course_to_group_from_csv.py
index 90ecfb88..4b37c18e 100644
--- a/Scripts/API_Tests/add_course_to_group_from_csv.py
+++ b/Scripts/API_Tests/add_course_to_group_from_csv.py
@@ -9,13 +9,35 @@ BASEFILE = "~/Downloads/Supplier Academy Course Groupings.csv"
def parse_csv():
df = pd.read_csv(BASEFILE)
- unique_groups = df['group_uuid'].nunique()
+ unique_groups = df['group_uuid'].unique().tolist()
+ unique_group_name = df['group_name'].unique().tolist()
groups = df.groupby('group_uuid')
for key,item in groups:
- print(groups.get_group(key), "\n\n")
+ pass
+ # print(groups.get_group(key), "\n\n")
print(f"Total Number of courses: {df['course_name'].nunique()}")
- print(f"Number of Unique Groups: {unique_groups}")
+ print(unique_group_name, unique_groups)
+ # print(f"Number of Unique Groups: {unique_groups}")
+ remove_group_courses(unique_groups)
+
+def remove_group_courses(unique_groups):
+ """
+ From Bartosz Chodyla: There's a non-public endpoint:
+ /v1/group_courses/:id
+ where id is the UUID of a record from the group_courses table. You can get the UUIDs directly from the DB or by calling another non-public endpoint, which is:
+ /v1/groups/:group_uuid/courses
+ """
+ print(unique_groups)
+ for group_uuid in unique_groups:
+ print(group_uuid)
+ # Get Group Courses
+ get_gcourses = f"https://api2.northpass.com/v1/groups/{group_uuid}/courses"
+ group_courses = requests.get(get_gcourses, headers=HEADERS)
+ gcourse_json = group_courses.json()
+ print(gcourse_json)
+
+
if __name__ == "__main__":
parse_csv()