Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
b55362b9
Commit
b55362b9
authored
Aug 08, 2014
by
Jason Bau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make unit tests respect mongo port/host settings (with default)
settings are read in from environment variable
parent
25963797
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
99 additions
and
32 deletions
+99
-32
cms/envs/test.py
+11
-2
common/lib/xmodule/xmodule/contentstore/mongo.py
+1
-1
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+7
-3
common/lib/xmodule/xmodule/modulestore/tests/mongo_connection.py
+10
-0
common/lib/xmodule/xmodule/modulestore/tests/test_contentstore.py
+4
-3
common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py
+4
-2
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+5
-2
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+6
-5
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
+3
-1
common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py
+3
-1
common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py
+4
-2
lms/djangoapps/dashboard/git_import.py
+4
-3
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
+4
-2
lms/djangoapps/dashboard/tests/test_sysadmin.py
+3
-2
lms/envs/test.py
+20
-2
pavelib/utils/test/utils.py
+10
-1
No files found.
cms/envs/test.py
View file @
b55362b9
...
@@ -21,6 +21,12 @@ from uuid import uuid4
...
@@ -21,6 +21,12 @@ from uuid import uuid4
# import settings from LMS for consistent behavior with CMS
# import settings from LMS for consistent behavior with CMS
from
lms.envs.test
import
(
WIKI_ENABLED
,
PLATFORM_NAME
,
SITE_NAME
)
from
lms.envs.test
import
(
WIKI_ENABLED
,
PLATFORM_NAME
,
SITE_NAME
)
# mongo connection settings
MONGO_PORT_NUM
=
int
(
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_PORT'
,
'27017'
))
MONGO_HOST
=
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_HOST'
,
'localhost'
)
THIS_UUID
=
uuid4
()
.
hex
[:
5
]
# Nose Test Runner
# Nose Test Runner
TEST_RUNNER
=
'django_nose.NoseTestSuiteRunner'
TEST_RUNNER
=
'django_nose.NoseTestSuiteRunner'
...
@@ -79,15 +85,18 @@ update_module_store_settings(
...
@@ -79,15 +85,18 @@ update_module_store_settings(
},
},
doc_store_settings
=
{
doc_store_settings
=
{
'db'
:
'test_xmodule'
,
'db'
:
'test_xmodule'
,
'collection'
:
'test_modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'collection'
:
'test_modulestore{0}'
.
format
(
THIS_UUID
),
},
},
)
)
CONTENTSTORE
=
{
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'DOC_STORE_CONFIG'
:
{
'DOC_STORE_CONFIG'
:
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'db'
:
'test_xcontent'
,
'db'
:
'test_xcontent'
,
'port'
:
MONGO_PORT_NUM
,
'collection'
:
'dont_trip'
,
'collection'
:
'dont_trip'
,
},
},
# allow for additional options that can be keyed on a name, e.g. 'trashcan'
# allow for additional options that can be keyed on a name, e.g. 'trashcan'
...
...
common/lib/xmodule/xmodule/contentstore/mongo.py
View file @
b55362b9
...
@@ -25,7 +25,7 @@ class MongoContentStore(ContentStore):
...
@@ -25,7 +25,7 @@ class MongoContentStore(ContentStore):
:param collection: ignores but provided for consistency w/ other doc_store_config patterns
:param collection: ignores but provided for consistency w/ other doc_store_config patterns
"""
"""
logging
.
debug
(
'Using MongoDB for static content serving at host={0}
db={1}'
.
format
(
hos
t
,
db
))
logging
.
debug
(
'Using MongoDB for static content serving at host={0}
port={1} db={2}'
.
format
(
host
,
por
t
,
db
))
_db
=
pymongo
.
database
.
Database
(
_db
=
pymongo
.
database
.
Database
(
pymongo
.
MongoClient
(
pymongo
.
MongoClient
(
host
=
host
,
host
=
host
,
...
...
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
b55362b9
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
"""
"""
Modulestore configuration for test cases.
Modulestore configuration for test cases.
"""
"""
from
uuid
import
uuid4
from
uuid
import
uuid4
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
...
@@ -13,6 +12,7 @@ import datetime
...
@@ -13,6 +12,7 @@ import datetime
import
pytz
import
pytz
from
xmodule.tabs
import
CoursewareTab
,
CourseInfoTab
,
StaticTab
,
DiscussionTab
,
ProgressTab
,
WikiTab
from
xmodule.tabs
import
CoursewareTab
,
CourseInfoTab
,
StaticTab
,
DiscussionTab
,
ProgressTab
,
WikiTab
from
xmodule.modulestore.tests.sample_courses
import
default_block_info_tree
,
TOY_BLOCK_INFO_TREE
from
xmodule.modulestore.tests.sample_courses
import
default_block_info_tree
,
TOY_BLOCK_INFO_TREE
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
def
mixed_store_config
(
data_dir
,
mappings
):
def
mixed_store_config
(
data_dir
,
mappings
):
...
@@ -67,7 +67,8 @@ def draft_mongo_store_config(data_dir):
...
@@ -67,7 +67,8 @@ def draft_mongo_store_config(data_dir):
'NAME'
:
'draft'
,
'NAME'
:
'draft'
,
'ENGINE'
:
'xmodule.modulestore.mongo.draft.DraftModuleStore'
,
'ENGINE'
:
'xmodule.modulestore.mongo.draft.DraftModuleStore'
,
'DOC_STORE_CONFIG'
:
{
'DOC_STORE_CONFIG'
:
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'db'
:
'test_xmodule'
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
'collection'
:
'modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
},
},
...
@@ -93,7 +94,8 @@ def split_mongo_store_config(data_dir):
...
@@ -93,7 +94,8 @@ def split_mongo_store_config(data_dir):
'NAME'
:
'draft'
,
'NAME'
:
'draft'
,
'ENGINE'
:
'xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore'
,
'ENGINE'
:
'xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore'
,
'DOC_STORE_CONFIG'
:
{
'DOC_STORE_CONFIG'
:
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'db'
:
'test_xmodule'
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
'collection'
:
'modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
},
},
...
@@ -229,6 +231,8 @@ class ModuleStoreTestCase(TestCase):
...
@@ -229,6 +231,8 @@ class ModuleStoreTestCase(TestCase):
if
hasattr
(
module_store
,
'_drop_database'
):
if
hasattr
(
module_store
,
'_drop_database'
):
module_store
.
_drop_database
()
# pylint: disable=protected-access
module_store
.
_drop_database
()
# pylint: disable=protected-access
_CONTENTSTORE
.
clear
()
_CONTENTSTORE
.
clear
()
if
hasattr
(
module_store
,
'close_connections'
):
module_store
.
close_connections
()
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
...
...
common/lib/xmodule/xmodule/modulestore/tests/mongo_connection.py
0 → 100644
View file @
b55362b9
"""
This file is intended to provide settings for the mongodb connection used for tests.
The settings can be provided by environment variables in the shell running the tests. This reads
in a variety of environment variables but provides sensible defaults in case those env var
overrides don't exist
"""
import
os
MONGO_PORT_NUM
=
int
(
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_PORT'
,
'27017'
))
MONGO_HOST
=
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_HOST'
,
'localhost'
)
common/lib/xmodule/xmodule/modulestore/tests/test_contentstore.py
View file @
b55362b9
"""
"""
Test contentstore.mongo functionality
Test contentstore.mongo functionality
"""
"""
import
os
import
logging
import
logging
from
uuid
import
uuid4
from
uuid
import
uuid4
import
unittest
import
unittest
...
@@ -17,12 +18,12 @@ from xmodule.contentstore.content import StaticContent
...
@@ -17,12 +18,12 @@ from xmodule.contentstore.content import StaticContent
from
xmodule.exceptions
import
NotFoundError
from
xmodule.exceptions
import
NotFoundError
import
ddt
import
ddt
from
__builtin__
import
delattr
from
__builtin__
import
delattr
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
HOST
=
'localhost'
HOST
=
MONGO_HOST
PORT
=
27017
PORT
=
MONGO_PORT_NUM
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py
View file @
b55362b9
...
@@ -11,7 +11,6 @@ and then for each combination of modulestores, performing the sequence:
...
@@ -11,7 +11,6 @@ and then for each combination of modulestores, performing the sequence:
4) Compare all modules in the source and destination modulestores to make sure that they line up
4) Compare all modules in the source and destination modulestores to make sure that they line up
"""
"""
import
ddt
import
ddt
import
itertools
import
itertools
import
random
import
random
...
@@ -28,9 +27,12 @@ from xmodule.contentstore.mongo import MongoContentStore
...
@@ -28,9 +27,12 @@ from xmodule.contentstore.mongo import MongoContentStore
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.modulestore.xml_exporter
import
export_to_xml
from
xmodule.modulestore.xml_exporter
import
export_to_xml
from
xmodule.modulestore.split_mongo.split_draft
import
DraftVersioningModuleStore
from
xmodule.modulestore.split_mongo.split_draft
import
DraftVersioningModuleStore
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
COMMON_DOCSTORE_CONFIG
=
{
COMMON_DOCSTORE_CONFIG
=
{
'host'
:
'localhost'
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
}
}
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
b55362b9
...
@@ -15,6 +15,7 @@ from xmodule.exceptions import InvalidVersionError
...
@@ -15,6 +15,7 @@ from xmodule.exceptions import InvalidVersionError
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
CourseLocator
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
CourseLocator
# Mixed modulestore depends on django, so we'll manually configure some django settings
# Mixed modulestore depends on django, so we'll manually configure some django settings
# before importing the module
# before importing the module
# TODO remove this import and the configuration -- xmodule should not depend on django!
# TODO remove this import and the configuration -- xmodule should not depend on django!
...
@@ -26,6 +27,7 @@ if not settings.configured:
...
@@ -26,6 +27,7 @@ if not settings.configured:
settings
.
configure
()
settings
.
configure
()
from
xmodule.modulestore.mixed
import
MixedModuleStore
from
xmodule.modulestore.mixed
import
MixedModuleStore
from
xmodule.modulestore.draft_and_published
import
UnsupportedRevisionError
from
xmodule.modulestore.draft_and_published
import
UnsupportedRevisionError
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
@ddt.ddt
@ddt.ddt
...
@@ -34,8 +36,8 @@ class TestMixedModuleStore(unittest.TestCase):
...
@@ -34,8 +36,8 @@ class TestMixedModuleStore(unittest.TestCase):
Quasi-superclass which tests Location based apps against both split and mongo dbs (Locator and
Quasi-superclass which tests Location based apps against both split and mongo dbs (Locator and
Location-based dbs)
Location-based dbs)
"""
"""
HOST
=
'localhost'
HOST
=
MONGO_HOST
PORT
=
27017
PORT
=
MONGO_PORT_NUM
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
COLLECTION
=
'modulestore'
COLLECTION
=
'modulestore'
FS_ROOT
=
DATA_DIR
FS_ROOT
=
DATA_DIR
...
@@ -54,6 +56,7 @@ class TestMixedModuleStore(unittest.TestCase):
...
@@ -54,6 +56,7 @@ class TestMixedModuleStore(unittest.TestCase):
}
}
DOC_STORE_CONFIG
=
{
DOC_STORE_CONFIG
=
{
'host'
:
HOST
,
'host'
:
HOST
,
'port'
:
PORT
,
'db'
:
DB
,
'db'
:
DB
,
'collection'
:
COLLECTION
,
'collection'
:
COLLECTION
,
}
}
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
b55362b9
...
@@ -36,12 +36,12 @@ from xmodule.exceptions import NotFoundError
...
@@ -36,12 +36,12 @@ from xmodule.exceptions import NotFoundError
from
git.test.lib.asserts
import
assert_not_none
from
git.test.lib.asserts
import
assert_not_none
from
xmodule.x_module
import
XModuleMixin
from
xmodule.x_module
import
XModuleMixin
from
xmodule.modulestore.mongo.base
import
as_draft
from
xmodule.modulestore.mongo.base
import
as_draft
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
HOST
=
'localhost'
HOST
=
MONGO_HOST
PORT
=
27017
PORT
=
MONGO_PORT_NUM
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
COLLECTION
=
'modulestore'
COLLECTION
=
'modulestore'
FS_ROOT
=
DATA_DIR
# TODO (vshnayder): will need a real fs_root for testing load_item
FS_ROOT
=
DATA_DIR
# TODO (vshnayder): will need a real fs_root for testing load_item
...
@@ -91,12 +91,13 @@ class TestMongoModuleStore(unittest.TestCase):
...
@@ -91,12 +91,13 @@ class TestMongoModuleStore(unittest.TestCase):
# connect to the db
# connect to the db
doc_store_config
=
{
doc_store_config
=
{
'host'
:
HOST
,
'host'
:
HOST
,
'port'
:
PORT
,
'db'
:
DB
,
'db'
:
DB
,
'collection'
:
COLLECTION
,
'collection'
:
COLLECTION
,
}
}
# since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
# since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
# as well
# as well
content_store
=
MongoContentStore
(
HOST
,
DB
)
content_store
=
MongoContentStore
(
HOST
,
DB
,
port
=
PORT
)
#
#
# Also test draft store imports
# Also test draft store imports
#
#
...
@@ -148,7 +149,7 @@ class TestMongoModuleStore(unittest.TestCase):
...
@@ -148,7 +149,7 @@ class TestMongoModuleStore(unittest.TestCase):
def
test_mongo_modulestore_type
(
self
):
def
test_mongo_modulestore_type
(
self
):
store
=
DraftModuleStore
(
store
=
DraftModuleStore
(
None
,
None
,
{
'host'
:
HOST
,
'db'
:
DB
,
'collection'
:
COLLECTION
},
{
'host'
:
HOST
,
'db'
:
DB
,
'
port'
:
PORT
,
'
collection'
:
COLLECTION
},
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
)
assert_equals
(
store
.
get_modulestore_type
(
''
),
ModuleStoreEnum
.
Type
.
mongo
)
assert_equals
(
store
.
get_modulestore_type
(
''
),
ModuleStoreEnum
.
Type
.
mongo
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
View file @
b55362b9
...
@@ -22,6 +22,7 @@ from xmodule.x_module import XModuleMixin
...
@@ -22,6 +22,7 @@ from xmodule.x_module import XModuleMixin
from
xmodule.fields
import
Date
,
Timedelta
from
xmodule.fields
import
Date
,
Timedelta
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
xmodule.modulestore.tests.test_modulestore
import
check_has_course_method
from
xmodule.modulestore.tests.test_modulestore
import
check_has_course_method
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
BRANCH_NAME_DRAFT
=
ModuleStoreEnum
.
BranchName
.
draft
BRANCH_NAME_DRAFT
=
ModuleStoreEnum
.
BranchName
.
draft
...
@@ -36,8 +37,9 @@ class SplitModuleTest(unittest.TestCase):
...
@@ -36,8 +37,9 @@ class SplitModuleTest(unittest.TestCase):
'''
'''
# Snippets of what would be in the django settings envs file
# Snippets of what would be in the django settings envs file
DOC_STORE_CONFIG
=
{
DOC_STORE_CONFIG
=
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'db'
:
'test_xmodule'
,
'db'
:
'test_xmodule'
,
'port'
:
MONGO_PORT_NUM
,
'collection'
:
'modulestore{0}'
.
format
(
uuid
.
uuid4
()
.
hex
[:
5
]),
'collection'
:
'modulestore{0}'
.
format
(
uuid
.
uuid4
()
.
hex
[:
5
]),
}
}
modulestore_options
=
{
modulestore_options
=
{
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py
View file @
b55362b9
...
@@ -9,6 +9,7 @@ from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator
...
@@ -9,6 +9,7 @@ from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
xmodule.modulestore.mongo
import
DraftMongoModuleStore
from
xmodule.modulestore.mongo
import
DraftMongoModuleStore
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
class
SplitWMongoCourseBoostrapper
(
unittest
.
TestCase
):
class
SplitWMongoCourseBoostrapper
(
unittest
.
TestCase
):
...
@@ -27,7 +28,8 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase):
...
@@ -27,7 +28,8 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase):
"""
"""
# Snippet of what would be in the django settings envs file
# Snippet of what would be in the django settings envs file
db_config
=
{
db_config
=
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'db'
:
'test_xmodule'
,
'db'
:
'test_xmodule'
,
}
}
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py
View file @
b55362b9
...
@@ -10,6 +10,7 @@ from opaque_keys.edx.locations import Location
...
@@ -10,6 +10,7 @@ from opaque_keys.edx.locations import Location
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.inheritance
import
InheritanceMixin
from
xmodule.modulestore.inheritance
import
InheritanceMixin
from
xmodule.modulestore.xml_importer
import
_import_module_and_update_references
from
xmodule.modulestore.xml_importer
import
_import_module_and_update_references
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.tests
import
DATA_DIR
from
xmodule.tests
import
DATA_DIR
from
uuid
import
uuid4
from
uuid
import
uuid4
...
@@ -21,8 +22,8 @@ class ModuleStoreNoSettings(unittest.TestCase):
...
@@ -21,8 +22,8 @@ class ModuleStoreNoSettings(unittest.TestCase):
"""
"""
A mixin to create a mongo modulestore that avoids settings
A mixin to create a mongo modulestore that avoids settings
"""
"""
HOST
=
'localhost'
HOST
=
MONGO_HOST
PORT
=
27017
PORT
=
MONGO_PORT_NUM
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
DB
=
'test_mongo_
%
s'
%
uuid4
()
.
hex
[:
5
]
COLLECTION
=
'modulestore'
COLLECTION
=
'modulestore'
FS_ROOT
=
DATA_DIR
FS_ROOT
=
DATA_DIR
...
@@ -36,6 +37,7 @@ class ModuleStoreNoSettings(unittest.TestCase):
...
@@ -36,6 +37,7 @@ class ModuleStoreNoSettings(unittest.TestCase):
}
}
DOC_STORE_CONFIG
=
{
DOC_STORE_CONFIG
=
{
'host'
:
HOST
,
'host'
:
HOST
,
'port'
:
PORT
,
'db'
:
DB
,
'db'
:
DB
,
'collection'
:
COLLECTION
,
'collection'
:
COLLECTION
,
}
}
...
...
lms/djangoapps/dashboard/git_import.py
View file @
b55362b9
...
@@ -128,6 +128,7 @@ def add_repo(repo, rdir_in, branch=None):
...
@@ -128,6 +128,7 @@ def add_repo(repo, rdir_in, branch=None):
# Set defaults even if it isn't defined in settings
# Set defaults even if it isn't defined in settings
mongo_db
=
{
mongo_db
=
{
'host'
:
'localhost'
,
'host'
:
'localhost'
,
'port'
:
27017
,
'user'
:
''
,
'user'
:
''
,
'password'
:
''
,
'password'
:
''
,
'db'
:
'xlog'
,
'db'
:
'xlog'
,
...
@@ -135,7 +136,7 @@ def add_repo(repo, rdir_in, branch=None):
...
@@ -135,7 +136,7 @@ def add_repo(repo, rdir_in, branch=None):
# Allow overrides
# Allow overrides
if
hasattr
(
settings
,
'MONGODB_LOG'
):
if
hasattr
(
settings
,
'MONGODB_LOG'
):
for
config_item
in
[
'host'
,
'user'
,
'password'
,
'db'
,
]:
for
config_item
in
[
'host'
,
'user'
,
'password'
,
'db'
,
'port'
]:
mongo_db
[
config_item
]
=
settings
.
MONGODB_LOG
.
get
(
mongo_db
[
config_item
]
=
settings
.
MONGODB_LOG
.
get
(
config_item
,
mongo_db
[
config_item
])
config_item
,
mongo_db
[
config_item
])
...
@@ -258,13 +259,13 @@ def add_repo(repo, rdir_in, branch=None):
...
@@ -258,13 +259,13 @@ def add_repo(repo, rdir_in, branch=None):
cwd
=
os
.
path
.
abspath
(
cdir
)))
cwd
=
os
.
path
.
abspath
(
cdir
)))
# store import-command-run output in mongo
# store import-command-run output in mongo
mongouri
=
'mongodb://{user}:{password}@{host}/{db}'
.
format
(
**
mongo_db
)
mongouri
=
'mongodb://{user}:{password}@{host}
:{port}
/{db}'
.
format
(
**
mongo_db
)
try
:
try
:
if
mongo_db
[
'user'
]
and
mongo_db
[
'password'
]:
if
mongo_db
[
'user'
]
and
mongo_db
[
'password'
]:
mdb
=
mongoengine
.
connect
(
mongo_db
[
'db'
],
host
=
mongouri
)
mdb
=
mongoengine
.
connect
(
mongo_db
[
'db'
],
host
=
mongouri
)
else
:
else
:
mdb
=
mongoengine
.
connect
(
mongo_db
[
'db'
],
host
=
mongo_db
[
'host'
])
mdb
=
mongoengine
.
connect
(
mongo_db
[
'db'
],
host
=
mongo_db
[
'host'
]
,
port
=
mongo_db
[
'port'
]
)
except
mongoengine
.
connection
.
ConnectionError
:
except
mongoengine
.
connection
.
ConnectionError
:
log
.
exception
(
'Unable to connect to mongodb to save log, please '
log
.
exception
(
'Unable to connect to mongodb to save log, please '
'check MONGODB_LOG settings'
)
'check MONGODB_LOG settings'
)
...
...
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
View file @
b55362b9
"""
"""
Provide tests for git_add_course management command.
Provide tests for git_add_course management command.
"""
"""
import
logging
import
logging
import
os
import
os
import
shutil
import
shutil
...
@@ -21,9 +20,12 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
...
@@ -21,9 +20,12 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
import
dashboard.git_import
as
git_import
import
dashboard.git_import
as
git_import
from
dashboard.git_import
import
GitImportError
from
dashboard.git_import
import
GitImportError
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
TEST_MONGODB_LOG
=
{
TEST_MONGODB_LOG
=
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'user'
:
''
,
'user'
:
''
,
'password'
:
''
,
'password'
:
''
,
'db'
:
'test_xlog'
,
'db'
:
'test_xlog'
,
...
...
lms/djangoapps/dashboard/tests/test_sysadmin.py
View file @
b55362b9
"""
"""
Provide tests for sysadmin dashboard feature in sysadmin.py
Provide tests for sysadmin dashboard feature in sysadmin.py
"""
"""
import
glob
import
glob
import
os
import
os
import
re
import
re
...
@@ -30,10 +29,12 @@ from xmodule.modulestore.django import modulestore
...
@@ -30,10 +29,12 @@ from xmodule.modulestore.django import modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.xml
import
XMLModuleStore
from
xmodule.modulestore.xml
import
XMLModuleStore
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
TEST_MONGODB_LOG
=
{
TEST_MONGODB_LOG
=
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'user'
:
''
,
'user'
:
''
,
'password'
:
''
,
'password'
:
''
,
'db'
:
'test_xlog'
,
'db'
:
'test_xlog'
,
...
...
lms/envs/test.py
View file @
b55362b9
...
@@ -18,8 +18,14 @@ from path import path
...
@@ -18,8 +18,14 @@ from path import path
from
warnings
import
filterwarnings
,
simplefilter
from
warnings
import
filterwarnings
,
simplefilter
from
uuid
import
uuid4
from
uuid
import
uuid4
# mongo connection settings
MONGO_PORT_NUM
=
int
(
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_PORT'
,
'27017'
))
MONGO_HOST
=
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_HOST'
,
'localhost'
)
os
.
environ
[
'DJANGO_LIVE_TEST_SERVER_ADDRESS'
]
=
'localhost:8000-9000'
os
.
environ
[
'DJANGO_LIVE_TEST_SERVER_ADDRESS'
]
=
'localhost:8000-9000'
THIS_UUID
=
uuid4
()
.
hex
[:
5
]
# can't test start dates with this True, but on the other hand,
# can't test start dates with this True, but on the other hand,
# can test everything else :)
# can test everything else :)
FEATURES
[
'DISABLE_START_DATES'
]
=
True
FEATURES
[
'DISABLE_START_DATES'
]
=
True
...
@@ -118,16 +124,19 @@ update_module_store_settings(
...
@@ -118,16 +124,19 @@ update_module_store_settings(
'data_dir'
:
COMMON_TEST_DATA_ROOT
,
'data_dir'
:
COMMON_TEST_DATA_ROOT
,
},
},
doc_store_settings
=
{
doc_store_settings
=
{
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'db'
:
'test_xmodule'
,
'db'
:
'test_xmodule'
,
'collection'
:
'test_modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]
),
'collection'
:
'test_modulestore{0}'
.
format
(
THIS_UUID
),
},
},
)
)
CONTENTSTORE
=
{
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'DOC_STORE_CONFIG'
:
{
'DOC_STORE_CONFIG'
:
{
'host'
:
'localhost'
,
'host'
:
MONGO_HOST
,
'db'
:
'xcontent'
,
'db'
:
'xcontent'
,
'port'
:
MONGO_PORT_NUM
,
}
}
}
}
...
@@ -338,3 +347,12 @@ VERIFY_STUDENT["SOFTWARE_SECURE"] = {
...
@@ -338,3 +347,12 @@ VERIFY_STUDENT["SOFTWARE_SECURE"] = {
VIDEO_CDN_URL
=
{
VIDEO_CDN_URL
=
{
'CN'
:
'http://api.xuetangx.com/edx/video?s3_url='
'CN'
:
'http://api.xuetangx.com/edx/video?s3_url='
}
}
######### dashboard git log settings #########
MONGODB_LOG
=
{
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'user'
:
''
,
'password'
:
''
,
'db'
:
'xlog'
,
}
pavelib/utils/test/utils.py
View file @
b55362b9
...
@@ -3,6 +3,11 @@ Helper functions for test tasks
...
@@ -3,6 +3,11 @@ Helper functions for test tasks
"""
"""
from
paver.easy
import
sh
,
task
from
paver.easy
import
sh
,
task
from
pavelib.utils.envs
import
Env
from
pavelib.utils.envs
import
Env
import
os
MONGO_PORT_NUM
=
int
(
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_PORT'
,
'27017'
))
MONGO_HOST
=
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_HOST'
,
'localhost'
)
__test__
=
False
# do not collect
__test__
=
False
# do not collect
...
@@ -42,4 +47,8 @@ def clean_mongo():
...
@@ -42,4 +47,8 @@ def clean_mongo():
"""
"""
Clean mongo test databases
Clean mongo test databases
"""
"""
sh
(
"mongo {repo_root}/scripts/delete-mongo-test-dbs.js"
.
format
(
repo_root
=
Env
.
REPO_ROOT
))
sh
(
"mongo {host}:{port} {repo_root}/scripts/delete-mongo-test-dbs.js"
.
format
(
host
=
MONGO_HOST
,
port
=
MONGO_PORT_NUM
,
repo_root
=
Env
.
REPO_ROOT
,
))
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