Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
fd3c38ca
Commit
fd3c38ca
authored
Aug 08, 2016
by
Clinton Blackburn
Committed by
Clinton Blackburn
Aug 09, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added __str__ methods to the ProgramType and SeatType models
ECOM-5173
parent
e617b248
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
course_discovery/apps/course_metadata/models.py
+6
-0
course_discovery/apps/course_metadata/tests/factories.py
+8
-1
course_discovery/apps/course_metadata/tests/test_models.py
+15
-1
No files found.
course_discovery/apps/course_metadata/models.py
View file @
fd3c38ca
...
@@ -411,6 +411,9 @@ class SeatType(TimeStampedModel):
...
@@ -411,6 +411,9 @@ class SeatType(TimeStampedModel):
name
=
models
.
CharField
(
max_length
=
64
,
unique
=
True
)
name
=
models
.
CharField
(
max_length
=
64
,
unique
=
True
)
slug
=
AutoSlugField
(
populate_from
=
'name'
)
slug
=
AutoSlugField
(
populate_from
=
'name'
)
def
__str__
(
self
):
return
self
.
name
class
Seat
(
TimeStampedModel
):
class
Seat
(
TimeStampedModel
):
""" Seat model. """
""" Seat model. """
...
@@ -503,6 +506,9 @@ class ProgramType(TimeStampedModel):
...
@@ -503,6 +506,9 @@ class ProgramType(TimeStampedModel):
'of the course counted toward the completion of the program.'
),
'of the course counted toward the completion of the program.'
),
)
)
def
__str__
(
self
):
return
self
.
name
class
Program
(
TimeStampedModel
):
class
Program
(
TimeStampedModel
):
class
ProgramStatus
(
DjangoChoices
):
class
ProgramStatus
(
DjangoChoices
):
...
...
course_discovery/apps/course_metadata/tests/factories.py
View file @
fd3c38ca
...
@@ -12,7 +12,7 @@ from course_discovery.apps.core.tests.factories import PartnerFactory
...
@@ -12,7 +12,7 @@ from course_discovery.apps.core.tests.factories import PartnerFactory
from
course_discovery.apps.core.tests.utils
import
FuzzyURL
from
course_discovery.apps.core.tests.utils
import
FuzzyURL
from
course_discovery.apps.course_metadata.models
import
(
from
course_discovery.apps.course_metadata.models
import
(
Course
,
CourseRun
,
Organization
,
Person
,
Image
,
Video
,
Subject
,
Seat
,
Prerequisite
,
LevelType
,
Program
,
Course
,
CourseRun
,
Organization
,
Person
,
Image
,
Video
,
Subject
,
Seat
,
Prerequisite
,
LevelType
,
Program
,
AbstractSocialNetworkModel
,
CourseRunSocialNetwork
,
PersonSocialNetwork
,
ProgramType
AbstractSocialNetworkModel
,
CourseRunSocialNetwork
,
PersonSocialNetwork
,
ProgramType
,
SeatType
,
)
)
from
course_discovery.apps.ietf_language_tags.models
import
LanguageTag
from
course_discovery.apps.ietf_language_tags.models
import
LanguageTag
...
@@ -229,3 +229,10 @@ class CourseRunSocialNetworkFactory(AbstractSocialNetworkModelFactory):
...
@@ -229,3 +229,10 @@ class CourseRunSocialNetworkFactory(AbstractSocialNetworkModelFactory):
class
Meta
:
class
Meta
:
model
=
CourseRunSocialNetwork
model
=
CourseRunSocialNetwork
class
SeatTypeFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
(
object
):
model
=
SeatType
name
=
FuzzyText
()
course_discovery/apps/course_metadata/tests/test_models.py
View file @
fd3c38ca
...
@@ -316,7 +316,7 @@ class ProgramTests(TestCase):
...
@@ -316,7 +316,7 @@ class ProgramTests(TestCase):
factories
.
SeatFactory
(
type
=
'credit'
,
currency
=
currency
,
course_run
=
course_run
,
price
=
600
)
factories
.
SeatFactory
(
type
=
'credit'
,
currency
=
currency
,
course_run
=
course_run
,
price
=
600
)
factories
.
SeatFactory
(
type
=
'verified'
,
currency
=
currency
,
course_run
=
course_run
,
price
=
100
)
factories
.
SeatFactory
(
type
=
'verified'
,
currency
=
currency
,
course_run
=
course_run
,
price
=
100
)
applicable_seat_types
=
SeatType
.
objects
.
filter
(
slug__in
=
[
'credit'
,
'verified'
])
applicable_seat_types
=
SeatType
.
objects
.
filter
(
slug__in
=
[
'credit'
,
'verified'
])
program_type
=
factories
.
ProgramTypeFactory
(
name
=
'XSeries'
,
applicable_seat_types
=
applicable_seat_types
)
program_type
=
factories
.
ProgramTypeFactory
(
applicable_seat_types
=
applicable_seat_types
)
program
=
factories
.
ProgramFactory
(
type
=
program_type
,
courses
=
[
course_run
.
course
])
program
=
factories
.
ProgramFactory
(
type
=
program_type
,
courses
=
[
course_run
.
course
])
expected_price_ranges
=
[{
'currency'
:
'USD'
,
'min'
:
Decimal
(
100
),
'max'
:
Decimal
(
600
)}]
expected_price_ranges
=
[{
'currency'
:
'USD'
,
'min'
:
Decimal
(
100
),
'max'
:
Decimal
(
600
)}]
...
@@ -374,3 +374,17 @@ class CourseSocialNetworkTests(TestCase):
...
@@ -374,3 +374,17 @@ class CourseSocialNetworkTests(TestCase):
factories
.
CourseRunSocialNetworkFactory
(
course_run
=
self
.
course_run
,
type
=
'facebook'
)
factories
.
CourseRunSocialNetworkFactory
(
course_run
=
self
.
course_run
,
type
=
'facebook'
)
with
self
.
assertRaises
(
IntegrityError
):
with
self
.
assertRaises
(
IntegrityError
):
factories
.
CourseRunSocialNetworkFactory
(
course_run
=
self
.
course_run
,
type
=
'facebook'
)
factories
.
CourseRunSocialNetworkFactory
(
course_run
=
self
.
course_run
,
type
=
'facebook'
)
class
SeatTypeTests
(
TestCase
):
""" Tests of the SeatType model. """
def
test_str
(
self
):
seat_type
=
factories
.
SeatTypeFactory
()
self
.
assertEqual
(
str
(
seat_type
),
seat_type
.
name
)
class
ProgramTypeTests
(
TestCase
):
""" Tests of the ProgramType model. """
def
test_str
(
self
):
program_type
=
factories
.
ProgramTypeFactory
()
self
.
assertEqual
(
str
(
program_type
),
program_type
.
name
)
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