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
7ae0836f
Commit
7ae0836f
authored
12 years ago
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more tests of github_sync
parent
66d5c8ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
25 deletions
+30
-25
cms/djangoapps/github_sync/tests/__init__.py
+15
-1
cms/djangoapps/github_sync/tests/test_views.py
+15
-24
No files found.
cms/djangoapps/github_sync/tests/__init__.py
View file @
7ae0836f
from
django.test
import
TestCase
from
path
import
path
import
shutil
from
github_sync
import
import_from_github
,
export_to_github
,
load_repo_settings
from
github_sync
import
import_from_github
,
export_to_github
,
load_repo_settings
,
sync_all_with_github
,
sync_with_github
from
git
import
Repo
from
django.conf
import
settings
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
Location
from
override_settings
import
override_settings
from
github_sync.exceptions
import
GithubSyncError
from
mock
import
patch
,
Mock
REPO_DIR
=
settings
.
GITHUB_REPO_ROOT
/
'local_repo'
WORKING_DIR
=
path
(
settings
.
TEST_ROOT
)
...
...
@@ -59,6 +60,19 @@ class GithubSyncTestCase(TestCase):
[
child
.
location
for
child
in
self
.
import_course
.
get_children
()])
self
.
assertEquals
(
1
,
len
(
self
.
import_course
.
get_children
()))
@patch
(
'github_sync.sync_with_github'
)
def
test_sync_all_with_github
(
self
,
sync_with_github
):
sync_all_with_github
()
sync_with_github
.
assert_called_with
(
load_repo_settings
(
'local_repo'
))
def
test_sync_with_github
(
self
):
with
patch
(
'github_sync.import_from_github'
,
Mock
(
return_value
=
(
Mock
(),
Mock
())))
as
import_from_github
:
with
patch
(
'github_sync.export_to_github'
)
as
export_to_github
:
settings
=
load_repo_settings
(
'local_repo'
)
sync_with_github
(
settings
)
import_from_github
.
assert_called_with
(
settings
)
export_to_github
.
assert_called
@override_settings
(
MITX_FEATURES
=
{
'GITHUB_PUSH'
:
False
})
def
test_export_no_pash
(
self
):
"""
...
...
This diff is collapsed.
Click to expand it.
cms/djangoapps/github_sync/tests/test_views.py
View file @
7ae0836f
import
json
from
django.test.client
import
Client
from
django.test
import
TestCase
from
mock
import
patch
,
Mock
from
mock
import
patch
from
override_settings
import
override_settings
from
django.conf
import
settings
from
github_sync
import
load_repo_
settings
@override_settings
(
REPOS
=
{
'repo'
:
{
'
path'
:
'path'
,
'branch'
:
'branch
'
}})
@override_settings
(
REPOS
=
{
'repo'
:
{
'
branch'
:
'branch'
,
'origin'
:
'origin
'
}})
class
PostReceiveTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
client
=
Client
()
@patch
(
'github_sync.views.export_to_github'
)
@patch
(
'github_sync.views.import_from_github'
)
def
test_non_branch
(
self
,
import_from_github
,
export_to_github
):
@patch
(
'github_sync.views.sync_with_github'
)
def
test_non_branch
(
self
,
sync_with_github
):
self
.
client
.
post
(
'/github_service_hook'
,
{
'payload'
:
json
.
dumps
({
'ref'
:
'refs/tags/foo'
})
})
self
.
assertFalse
(
import_from_github
.
called
)
self
.
assertFalse
(
export_to_github
.
called
)
self
.
assertFalse
(
sync_with_github
.
called
)
@patch
(
'github_sync.views.export_to_github'
)
@patch
(
'github_sync.views.import_from_github'
)
def
test_non_watched_repo
(
self
,
import_from_github
,
export_to_github
):
@patch
(
'github_sync.views.sync_with_github'
)
def
test_non_watched_repo
(
self
,
sync_with_github
):
self
.
client
.
post
(
'/github_service_hook'
,
{
'payload'
:
json
.
dumps
({
'ref'
:
'refs/heads/branch'
,
'repository'
:
{
'name'
:
'bad_repo'
}})
})
self
.
assertFalse
(
import_from_github
.
called
)
self
.
assertFalse
(
export_to_github
.
called
)
self
.
assertFalse
(
sync_with_github
.
called
)
@patch
(
'github_sync.views.export_to_github'
)
@patch
(
'github_sync.views.import_from_github'
)
def
test_non_tracked_branch
(
self
,
import_from_github
,
export_to_github
):
@patch
(
'github_sync.views.sync_with_github'
)
def
test_non_tracked_branch
(
self
,
sync_with_github
):
self
.
client
.
post
(
'/github_service_hook'
,
{
'payload'
:
json
.
dumps
({
'ref'
:
'refs/heads/non_branch'
,
'repository'
:
{
'name'
:
'repo'
}})
})
self
.
assertFalse
(
import_from_github
.
called
)
self
.
assertFalse
(
export_to_github
.
called
)
self
.
assertFalse
(
sync_with_github
.
called
)
@patch
(
'github_sync.views.export_to_github'
)
@patch
(
'github_sync.views.import_from_github'
,
return_value
=
(
Mock
(),
Mock
()))
def
test_tracked_branch
(
self
,
import_from_github
,
export_to_github
):
@patch
(
'github_sync.views.sync_with_github'
)
def
test_tracked_branch
(
self
,
sync_with_github
):
self
.
client
.
post
(
'/github_service_hook'
,
{
'payload'
:
json
.
dumps
({
'ref'
:
'refs/heads/branch'
,
'repository'
:
{
'name'
:
'repo'
}})
})
import_from_github
.
assert_called_with
(
settings
.
REPOS
[
'repo'
])
mock_revision
,
mock_course
=
import_from_github
.
return_value
export_to_github
.
assert_called_with
(
mock_course
,
'path'
,
"Changes from cms import of revision
%
s"
%
mock_revision
)
sync_with_github
.
assert_called_with
(
load_repo_settings
(
'repo'
))
This diff is collapsed.
Click to expand it.
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