describe('example.personalLog.LogCtrl', function() { var logScope; beforeEach(module('personalLog')); beforeEach(inject(function($rootScope, $controller) { logScope = $rootScope.$new(); $controller('LogCtrl', {$scope: logScope}); })); it('should initialize notes with an empty array', function() { expect(logScope.logs).toEqual([]); }); describe('addLog', function() { beforeEach(function() { expect(logScope.logs).toEqual([]); }); it('should add newMsg to logs as a log entry', function() { logScope.newMsg = 'first log message'; logScope.addLog(); expect(logScope.logs.length).toBe(1); expect(logScope.logs[0].msg).toBe('first log message'); //one more msg, this time passed in as param logScope.addLog('second log message'); expect(logScope.logs.length).toBe(2); expect(logScope.logs[0].msg).toBe('first log message'); expect(logScope.logs[1].msg).toBe('second log message'); }); it('should clear newMsg when log entry is persisted', function() { logScope.addLog('first log message'); expect(logScope.newMsg).toBe(''); }); it('should store logs in the logs cookie', inject(function($cookies) { expect($cookies.logs).not.toBeDefined(); logScope.addLog('first log message'); expect($cookies.logs).toBeTruthy(); })); it('should do nothing if newMsg is empty', function() { logScope.addLog(''); expect(logScope.logs.length).toBe(0); }); }); describe('rmLog', function() { beforeEach(function() { logScope.addLog('message1'); logScope.addLog('message2'); logScope.addLog('message3'); logScope.addLog('message4'); expect(logScope.logs.length).toBe(4); }); it('should delete a message identified by index', function() { logScope.rmLog(logScope.logs[1]); expect(logScope.logs.length).toBe(3); logScope.rmLog(logScope.logs[2]); expect(logScope.logs.length).toBe(2); expect(logScope.logs[0].msg).toBe('message1'); expect(logScope.logs[1].msg).toBe('message3'); }); it('should update cookies when a log is deleted', inject(function($cookies) { expect($cookies.logs).toMatch(/\[\{.*?\}(,\{.*?\}){3}\]/); logScope.rmLog(logScope.logs[1]); expect($cookies.logs).toMatch(/\[\{.*?\}(,\{.*?\}){2}\]/); logScope.rmLog(logScope.logs[0]); logScope.rmLog(logScope.logs[0]); logScope.rmLog(logScope.logs[0]); expect($cookies.logs).toMatch(/\[\]/); })); }); describe('rmLogs', function() { beforeEach(function() { logScope.addLog('message1'); logScope.addLog('message2'); logScope.addLog('message3'); logScope.addLog('message4'); expect(logScope.logs.length).toBe(4); }); it('should remove all logs', function() { logScope.rmLogs(); expect(logScope.logs).toEqual([]); }); it('should remove logs cookie', inject(function($cookies) { expect($cookies.logs).toBeTruthy(); logScope.rmLogs(); expect($cookies.logs).not.toBeDefined(); })); }); }); summary='blob content' class='blob'>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup
import re
import os
import sys
def get_version(package):
"""
Return package version as listed in `__version__` in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
return re.match("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
def get_packages(package):
"""
Return root package and all sub-packages.
"""
return [dirpath
for dirpath, dirnames, filenames in os.walk(package)
if os.path.exists(os.path.join(dirpath, '__init__.py'))]
def get_package_data(package):
"""
Return all files under the root package, that are not in a
package themselves.
"""
walk = [(dirpath.replace(package + os.sep, '', 1), filenames)
for dirpath, dirnames, filenames in os.walk(package)
if not os.path.exists(os.path.join(dirpath, '__init__.py'))]
filepaths = []
for base, filenames in walk:
filepaths.extend([os.path.join(base, filename)
for filename in filenames])
return {package: filepaths}
version = get_version('rest_framework')
if sys.argv[-1] == 'publish':
os.system("python setup.py sdist upload")
print("You probably want to also tag the version now:")
print(" git tag -a %s -m 'version %s'" % (version, version))
print(" git push --tags")
sys.exit()
setup(
name='djangorestframework',
version=version,
url='http://django-rest-framework.org',
download_url='http://pypi.python.org/pypi/rest_framework/',
license='BSD',
description='Web APIs for Django, made easy.',
author='Tom Christie',
author_email='tom@tomchristie.com', # SEE NOTE BELOW (*)
packages=get_packages('rest_framework'),
package_data=get_package_data('rest_framework'),
test_suite='rest_framework.runtests.runtests.main',
install_requires=[],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP',
]
)
# (*) Please direct queries to the discussion group, rather than to me directly
# Doing so helps ensure your question is helpful to other users.
# Queries directly to my email are likely to receive a canned response.
#
# Many thanks for your understanding.