Skip to content

Commit 2968ea0

Browse files
fix tooling
1 parent 4c9d6dd commit 2968ea0

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

openedx_events/learning/data.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
Data attributes for events within the architecture subdomain `learning`. These
3+
attributes follow the form of attr objects specified in OEP-49 data pattern.
4+
"""
5+
6+
from datetime import datetime
7+
from typing import Dict
8+
9+
import attr
10+
from opaque_keys.edx.keys import CourseKey
11+
12+
13+
@attr.s(frozen=True)
14+
class ProfileData:
15+
"""
16+
Attributes defined for Open edX student's profile object.
17+
"""
18+
meta = attr.ib(type=Dict[str, str], factory=dict)
19+
name = attr.ib(type=str, factory=str)
20+
21+
22+
@attr.s(frozen=True)
23+
class StudentData:
24+
"""
25+
Attributes defined for Open edX student object.
26+
"""
27+
username = attr.ib(type=str)
28+
email = attr.ib(type=str)
29+
first_name = attr.ib(type=str, factory=str)
30+
last_name = attr.ib(type=str, factory=str)
31+
is_active = attr.ib(type=bool, default=False)
32+
profile = attr.ib(type=ProfileData, default=ProfileData())
33+
34+
35+
@attr.s(frozen=True)
36+
class RegistrationData:
37+
"""
38+
Attributes defined for Open edX registration profile object.
39+
"""
40+
activation_key = attr.ib(type=str)
41+
42+
43+
@attr.s(frozen=True)
44+
class CourseData:
45+
"""
46+
Attributes defined for Open edX course object.
47+
"""
48+
course_key = attr.ib(type=CourseKey)
49+
display_name = attr.ib(type=CourseKey, factory=str)
50+
51+
52+
@attr.s(frozen=True)
53+
class EnrollmentData:
54+
"""
55+
Attributes defined for Open edX Course Enrollment object.
56+
"""
57+
user = attr.ib(type=StudentData)
58+
course = attr.ib(type=CourseData)
59+
mode = attr.ib(type=str)
60+
61+
62+
@attr.s(frozen=True)
63+
class CertificateData(EnrollmentData):
64+
"""
65+
Attributes defined for Open edX Course Enrollment object.
66+
"""
67+
status = attr.ib(type=str)
68+
available_date = attr.ib(type=datetime)
69+
70+
71+
@attr.s(frozen=True)
72+
class CohortData:
73+
"""
74+
Attributes defined for Open edX Course Enrollment object.
75+
"""
76+
user = attr.ib(type=StudentData)
77+
course = attr.ib(type=CourseData)

openedx_events/tooling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class OpenEdxPublicSignal(Signal):
1616
"""Custom class used to create Open edX events.
1717
"""
1818

19-
def __init__(self, event_type=None, data=None, minor_version='0.0'):
19+
def __init__(self, event_type=None, data=None, minor_version="0.0"):
2020
if not event_type or not data:
2121
raise InstantiationException(event_type=event_type)
2222
self.data = data
@@ -36,7 +36,7 @@ def get_signal_metadata(self):
3636
def get_current_time():
3737
"""Helper function used to get timestamp when the event ocurred.
3838
"""
39-
return str(datetime.utcnow().isoformat()) + 'Z'
39+
return str(datetime.utcnow().isoformat()) + "Z"
4040

4141
def get_source():
4242
"""Helper function used to get logical source of an event.

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)