Skip to content

Commit

Permalink
Renamed python files to prevent
Browse files Browse the repository at this point in the history
expection after installation from package control related to import order
  • Loading branch information
condemil committed Jul 29, 2017
1 parent c2545bc commit 6192593
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 49 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion gist_request.py → gist_40_request.py
Expand Up @@ -8,7 +8,7 @@

import urllib.request as urllib

from exceptions import MissingCredentialsException, SimpleHTTPError
from gist_20_exceptions import MissingCredentialsException, SimpleHTTPError


def token_auth_string():
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions gist.py → gist_80.py
Expand Up @@ -17,14 +17,14 @@

sys.path.append(os.path.dirname(os.path.realpath(__file__)))

from exceptions import MissingCredentialsException
from gist_helpers import (
from gist_20_exceptions import MissingCredentialsException
from gist_60_helpers import (
gistify_view,
gists_filter,
set_syntax,
ungistify_view,
)
from gist_request import api_request
from gist_40_request import api_request

settings = None

Expand Down
46 changes: 23 additions & 23 deletions test/test_commands.py
Expand Up @@ -2,7 +2,7 @@
from unittest import TestCase
from unittest.mock import Mock, patch

import gist
import gist_80 as gist
from test.stubs import github_api, sublime

DEFAULT_GISTS_URL = 'https://api.github.com/gists?per_page=100'
Expand All @@ -22,21 +22,21 @@ def test_gist_copy_url(self,):
gist_copy_url.run(edit=None)
sublime.set_clipboard.assert_called_with(None)

@patch('gist.webbrowser')
@patch('gist_80.webbrowser')
def test_gist_open_browser(self, patch_gist_webbrowser):
gist_open_browser = gist.GistOpenBrowser()
gist_open_browser.run(edit=None)
patch_gist_webbrowser.open.assert_called_with(None)

@patch('gist.api_request')
@patch('gist_80.api_request')
def test_gist_list_command_base(self, mocked_api_request):
gist.plugin_loaded()
mocked_api_request.side_effect = [github_api.GIST_STARRED_LIST, github_api.GIST_LIST]
gist.settings.set('include_users', ['some user'])
gist.settings.set('include_orgs', ['some org'])
gist_list_base = gist.GistListCommandBase()

with patch('gist.GistListCommandBase.get_window') as mocked_get_window:
with patch('gist_80.GistListCommandBase.get_window') as mocked_get_window:
mocked_window = Mock()
mocked_get_window.return_value = mocked_window
gist_list_base.run()
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_gist_list_command_base(self, mocked_api_request):
# pass flow
mocked_window.reset_mock()
mocked_api_request.reset_mock()
with patch('gist.GistListCommandBase.handle_gist') as mocked_handle_gist:
with patch('gist_80.GistListCommandBase.handle_gist') as mocked_handle_gist:
on_gist_num(-1)

self.assertEqual(mocked_api_request.call_count, 0)
Expand All @@ -81,7 +81,7 @@ def test_gist_list_command_base(self, mocked_api_request):
# personal gists flow
mocked_window.reset_mock()
mocked_api_request.reset_mock()
with patch('gist.GistListCommandBase.handle_gist') as mocked_handle_gist:
with patch('gist_80.GistListCommandBase.handle_gist') as mocked_handle_gist:
on_gist_num(0)

self.assertEqual(mocked_api_request.call_count, 0)
Expand Down Expand Up @@ -116,32 +116,32 @@ def test_gist_list_command_base(self, mocked_api_request):
self.assertRaises(NotImplementedError, gist_list_base.handle_gist, None)
self.assertRaises(NotImplementedError, gist_list_base.get_window)

@patch('gist.open_gist')
@patch('gist_80.open_gist')
def test_gist_list_command(self, mocked_open_gist):
mocked_window = Mock()
gist_list = gist.GistListCommand(mocked_window)
gist_list.handle_gist({'url': TEST_GIST_URL})
mocked_open_gist.assert_called_with(TEST_GIST_URL)
self.assertEqual(gist_list.get_window(), mocked_window)

@patch('gist.insert_gist')
@patch('gist_80.insert_gist')
def test_insert_gist_list_command(self, mocked_insert_gist):
mocked_window = Mock()
insert_gist_list = gist.InsertGistListCommand(mocked_window)
insert_gist_list.handle_gist({'url': TEST_GIST_URL})
mocked_insert_gist.assert_called_with(TEST_GIST_URL)
self.assertEqual(insert_gist_list.get_window(), mocked_window)

@patch('gist.insert_gist_embed')
@patch('gist_80.insert_gist_embed')
def test_insert_gist_embed_list_command(self, mocked_insert_gist_embed):
mocked_window = Mock()
insert_gist_embed_list = gist.InsertGistEmbedListCommand(mocked_window)
insert_gist_embed_list.handle_gist({'url': TEST_GIST_URL})
mocked_insert_gist_embed.assert_called_with(TEST_GIST_URL)
self.assertEqual(insert_gist_embed_list.get_window(), mocked_window)

@patch('gist.gistify_view')
@patch('gist.update_gist')
@patch('gist_80.gistify_view')
@patch('gist_80.update_gist')
def test_gist_add_file_command(self, mocked_update_gist, mocked_gistify_view):
add_file = gist.GistAddFileCommand()
add_file.handle_gist({'url': TEST_GIST_URL})
Expand Down Expand Up @@ -179,9 +179,9 @@ def test_gist_view_command(self):
self.assertEqual(gist_view_command.gist_filename(), 'some gist filename')
self.assertEqual(gist_view_command.gist_description(), 'some gist description')

@patch('gist.gistify_view')
@patch('gist_80.gistify_view')
@patch('test.stubs.sublime.Region')
@patch('gist.create_gist')
@patch('gist_80.create_gist')
def test_gist_command(self, mocked_create_gist, mocked_region, mocked_gistify_view):
gist_command = gist.GistCommand()
gist_command.view = sublime.View()
Expand Down Expand Up @@ -234,8 +234,8 @@ def test_gist_private_command(self):
gist_private_command = gist.GistPrivateCommand()
self.assertEqual(gist_private_command.mode(), 'Private')

@patch('gist.gistify_view')
@patch('gist.update_gist')
@patch('gist_80.gistify_view')
@patch('gist_80.update_gist')
def test_gist_rename_file_command(self, mocked_update_gist, mocked_gistify_view):
gist_rename_file = gist.GistRenameFileCommand()
mocked_update_gist.return_value = 'some updated gist'
Expand All @@ -254,8 +254,8 @@ def test_gist_rename_file_command(self, mocked_update_gist, mocked_gistify_view)
mocked_gistify_view.assert_called_with(gist_rename_file.view, 'some updated gist', 'some new filename')
sublime.status_message.assert_called_with('Gist file renamed')

@patch('gist.gistify_view')
@patch('gist.update_gist')
@patch('gist_80.gistify_view')
@patch('gist_80.update_gist')
def test_change_description_command(self, mocked_update_gist, mocked_gistify_view):
sublime._windows[0] = sublime.Window(0)
mocked_update_gist.return_value = 'some updated gist'
Expand All @@ -274,7 +274,7 @@ def test_change_description_command(self, mocked_update_gist, mocked_gistify_vie
mocked_gistify_view.assert_called_with(sublime._windows[0]._view, 'some updated gist', None)
sublime.status_message.assert_called_with('Gist description changed')

@patch('gist.update_gist')
@patch('gist_80.update_gist')
def test_gist_update_file_command(self, mocked_update_gist):
gist_update_file = gist.GistUpdateFileCommand()
gist_update_file.run(edit=False)
Expand All @@ -283,8 +283,8 @@ def test_gist_update_file_command(self, mocked_update_gist):

sublime.status_message.assert_called_with('Gist updated')

@patch('gist.ungistify_view')
@patch('gist.update_gist')
@patch('gist_80.ungistify_view')
@patch('gist_80.update_gist')
def test_gist_delete_file_command(self, mocked_update_gist, mocked_ungistify_view):
gist_delete_file = gist.GistDeleteFileCommand()
gist_delete_file.run(edit=False)
Expand All @@ -294,8 +294,8 @@ def test_gist_delete_file_command(self, mocked_update_gist, mocked_ungistify_vie

sublime.status_message.assert_called_with('Gist file deleted')

@patch('gist.ungistify_view')
@patch('gist.api_request')
@patch('gist_80.ungistify_view')
@patch('gist_80.api_request')
def test_gist_delete_command(self, mocked_api_request, mocked_ungistify_view):
gist_delete = gist.GistDeleteCommand()
gist_delete.run(edit=False)
Expand All @@ -305,7 +305,7 @@ def test_gist_delete_command(self, mocked_api_request, mocked_ungistify_view):

sublime.status_message.assert_called_with('Gist deleted')

@patch('gist.update_gist')
@patch('gist_80.update_gist')
def test_gist_listener(self, mocked_update_gist):
gist_listener = gist.GistListener()
gist.plugin_loaded()
Expand Down
32 changes: 16 additions & 16 deletions test/test_gist.py
Expand Up @@ -4,16 +4,16 @@
from unittest.mock import Mock, patch
from urllib.error import HTTPError

import gist_helpers
import gist
import gist_request
from exceptions import MissingCredentialsException, SimpleHTTPError
import gist_40_request as gist_request
import gist_60_helpers as gist_helpers
import gist_80 as gist
from gist_20_exceptions import MissingCredentialsException, SimpleHTTPError
from test.stubs import sublime
from test.stubs import github_api


class TestGist(TestCase):
@patch('gist.api_request')
@patch('gist_80.api_request')
def test_create_gist(self, mocked_api_request):
gist.plugin_loaded()
description = 'some description'
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_create_gist_fail(self):
gist.create_gist(public, description, failed_files)
sublime.error_message.assert_called_with('Gist: Unable to create a Gist with empty content')

@patch('gist.api_request')
@patch('gist_80.api_request')
def test_update_gist(self, mocked_api_request):
gist_url = 'some gist url'
file_changes = 'some file changes'
Expand All @@ -64,10 +64,10 @@ def test_update_gist(self, mocked_api_request):
method=http_method)
sublime.status_message.assert_called_with('Gist updated')

@patch('gist.set_syntax')
@patch('gist.gistify_view')
@patch('gist_80.set_syntax')
@patch('gist_80.gistify_view')
@patch('test.stubs.sublime.Window.new_file')
@patch('gist.api_request')
@patch('gist_80.api_request')
def test_open_gist(self, mocked_api_request, mocked_new_file, mocked_gistify_view, mocked_set_syntax):
gist_url = 'some gist url'
mocked_api_request.return_value = github_api.GIST_WITH_FILE_CONTENT_AND_TYPE
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_open_gist(self, mocked_api_request, mocked_new_file, mocked_gistify_vie
github_api.GIST_WITH_FILE_CONTENT_AND_TYPE['files']['some_file1.txt'])

@patch('test.stubs.sublime.Window.active_view')
@patch('gist.api_request')
@patch('gist_80.api_request')
def test_insert_gist(self, mocked_api_request, mocked_active_view):
gist_url = 'some gist url'
mocked_api_request.return_value = github_api.GIST_WITH_FILE_CONTENT_AND_TYPE
Expand All @@ -127,7 +127,7 @@ def test_insert_gist(self, mocked_api_request, mocked_active_view):
self.assertEqual(view.settings.return_value.set.call_count, 6)

@patch('test.stubs.sublime.Window.active_view')
@patch('gist.api_request')
@patch('gist_80.api_request')
def test_insert_gist_embed(self, mocked_api_request, mocked_active_view):
gist_url = 'some gist url'
mocked_api_request.return_value = github_api.GIST_WITH_RAW_URL
Expand All @@ -144,8 +144,8 @@ def test_insert_gist_embed(self, mocked_api_request, mocked_active_view):
{'characters': '<script src="some another raw url"></script>'})

@patch('test.stubs.sublime.Window.open_file')
@patch('gist.shutil.copy')
@patch('gist.traceback.print_exc')
@patch('gist_80.shutil.copy')
@patch('gist_80.traceback.print_exc')
def test_catch_errors(self, mocked_print_exc, mocked_copy, mocked_open_file):
gist.catch_errors(lambda: exec('raise(Exception())'))()
self.assertEqual(mocked_print_exc.call_count, 1)
Expand All @@ -158,7 +158,7 @@ def test_catch_errors(self, mocked_print_exc, mocked_copy, mocked_open_file):
mocked_copy.assert_called_with('Gist/Gist.sublime-settings', 'User/Gist.sublime-settings')
mocked_open_file.assert_called_with('User/Gist.sublime-settings')

@patch('gist_helpers.gist_title')
@patch('gist_60_helpers.gist_title')
def test_gistify_view(self, mocked_gist_title):
mocked_gist_title.return_value = ['some gist title']
view = sublime.View()
Expand Down Expand Up @@ -219,7 +219,7 @@ def test_gists_filter(self):
self.assertEqual(gists, [{'files': {'some_test2.sh': {}}, 'description': 'some_prefix:some gist 3 #some_tag'}])
self.assertEqual(gists_names, [['some gist 3']])

@patch('gist.os.name', 'nt')
@patch('gist_80.os.name', 'nt')
def test_set_syntax(self):
view = Mock()

Expand All @@ -243,7 +243,7 @@ def test_token_auth_string(self):

self.assertEqual(gist_request.token_auth_string(), 'some token')

@patch('gist_request.urllib')
@patch('gist_40_request.urllib')
def test_api_request(self, mocked_urllib):
url = 'https://url.test'
data = 'some data'
Expand Down
12 changes: 6 additions & 6 deletions test/test_settings.py
@@ -1,8 +1,8 @@
from unittest import TestCase
from unittest.mock import Mock, patch
from unittest.mock import patch

import gist
import gist_helpers
import gist_60_helpers as gist_helpers
import gist_80 as gist
from test.stubs import github_api, sublime

DEFAULT_GISTS_URL = 'https://api.github.com/gists?per_page=100'
Expand Down Expand Up @@ -41,7 +41,7 @@ def test_custom_url_setting(self):
self.assertEqual(gist.settings.get('STARRED_GISTS_URL'), CUSTOM_STARRED_GISTS_URL)
self.assertEqual(gist.settings.get('ORGS_URL'), CUSTOM_ORGS_URL)

@patch('gist.sublime.status_message')
@patch('gist_80.sublime.status_message')
def test_max_gists(self, patched_status_message):
gist.settings.set('max_gists', 101)
gist.set_settings()
Expand Down Expand Up @@ -88,8 +88,8 @@ def test_show_authors(self):
result = gist_helpers.gist_title(github_api.GIST_WITH_DESCRIPTION)
self.assertEqual(result, ['some description', 'some_user'])

@patch('gist.GistListCommandBase.get_window')
@patch('gist.api_request')
@patch('gist_80.GistListCommandBase.get_window')
@patch('gist_80.api_request')
def test_use_starred(self, mocked_api_request, mocked_get_window):
gist.plugin_loaded()
mocked_api_request.side_effect = [github_api.GIST_STARRED_LIST, github_api.GIST_LIST]
Expand Down

0 comments on commit 6192593

Please sign in to comment.