This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file 'gitignore', <<-CODE | |
/.bundle | |
/.idea | |
/.vagrant | |
# Ignore the default SQLite database. | |
/db/*.sqlite3 | |
/db/*.sqlite3-journal | |
# Ignore all logfiles and tempfiles. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: import mock | |
In [2]: mock_input = mock.MagicMock() | |
In [3]: with mock.patch('__builtin__.raw_input', mock_input): | |
...: mock_input.return_value = 'foobar' | |
...: foo = raw_input() | |
...: | |
In [4]: foo | |
Out[4]: 'foobar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_data_from_request(request): | |
""" | |
Convenience function to create data from a webapp2 request object. | |
:param request: | |
:return: dict | |
""" | |
# request.params combines the GET and POST data, this would give us some | |
# extra info to this particular request. | |
params = dict(request.params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For those on python27, looks like py27_optional is not being passed in (dev_appserver_import_hook.py:591) | |
if not FakeFile.IsFileAccessible(filename) | |
Simplest workaround is to change the method defaults from: | |
def IsFileAccessible(filename, normcase=os.path.normcase, py27_optional=False) | |
to: | |
def IsFileAccessible(filename, normcase=os.path.normcase, py27_optional=True) | |
# File is located at: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a script I use to setup MySQL on ramdisk | |
# after I need to reboot. This assumes that you already | |
# have MySQL installed and have previously moved your | |
# MySQL files to a backup location, e.g.: | |
# mv /var/lib/mysql /home/cgallemore/workspace/mysql | |
stop mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#In looking into the issue with being able to test with CSRF enabled, | |
#I've come up with a way to mock this out and wanted to see what you | |
#guys think before I move on. Here is a sample test of what this | |
#would look like: | |
@mock.patch.object(SessionStore, 'get_secure_cookie') | |
def test_can_add_order(self, mock_session): | |
mock_session.return_value = {'csrf_token': str(uuid4())} | |
self.login('[email protected]', admin = True) |