mirror of
https://github.com/docker/compose.git
synced 2026-02-16 13:32:31 +08:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
847ec5b559 | ||
|
|
09ffa101ed | ||
|
|
01e2b56405 | ||
|
|
2f6c763703 | ||
|
|
4caf90c581 | ||
|
|
8fdeb46430 | ||
|
|
07c47426ba | ||
|
|
a6324d6226 | ||
|
|
939406ca9d | ||
|
|
50a24bc3bf | ||
|
|
0dc55fda45 | ||
|
|
dcd8e7863f | ||
|
|
ed283fd3df | ||
|
|
393433b702 | ||
|
|
7516b67a14 | ||
|
|
5eac04d8d4 | ||
|
|
fec41d3567 | ||
|
|
c09734822e | ||
|
|
94887a28c7 | ||
|
|
262efce43e | ||
|
|
99064d17dd | ||
|
|
ed80576236 | ||
|
|
5131eaeba0 | ||
|
|
b559880a80 | ||
|
|
7f06d46827 | ||
|
|
e1a0937a61 | ||
|
|
59c976510c | ||
|
|
f189e299fd | ||
|
|
d08720247a | ||
|
|
a4df76dd3f | ||
|
|
b2e3a91098 | ||
|
|
47bbc35b74 | ||
|
|
a12f3b40d5 | ||
|
|
3386927f9f | ||
|
|
12d75a74e6 | ||
|
|
1a9c5e197d | ||
|
|
8fa85ecc05 | ||
|
|
140ced6a3b | ||
|
|
779f4bda01 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
*.egg-info
|
||||
*.pyc
|
||||
.tox
|
||||
/build
|
||||
/dist
|
||||
/docs/_site
|
||||
|
||||
@@ -16,6 +16,7 @@ before_script:
|
||||
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then orchard hosts create $TRAVIS_JOB_ID; fi'
|
||||
script:
|
||||
- nosetests tests/unit
|
||||
- flake8 fig
|
||||
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then script/travis-integration; fi'
|
||||
after_script:
|
||||
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then orchard hosts rm -f $TRAVIS_JOB_ID; fi'
|
||||
|
||||
11
CHANGES.md
11
CHANGES.md
@@ -1,6 +1,17 @@
|
||||
Change log
|
||||
==========
|
||||
|
||||
0.5.2 (2014-07-28)
|
||||
------------------
|
||||
|
||||
- Added a `--no-cache` option to `fig build`, which bypasses the cache just like `docker build --no-cache`.
|
||||
- Fixed the `dns:` fig.yml option, which was causing fig to error out.
|
||||
- Fixed a bug where fig couldn't start under Python 2.6.
|
||||
- Fixed a log-streaming bug that occasionally caused fig to exit.
|
||||
|
||||
Thanks @dnephin and @marksteve!
|
||||
|
||||
|
||||
0.5.1 (2014-07-11)
|
||||
------------------
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Development environment
|
||||
|
||||
If you're looking contribute to [Fig](http://orchardup.github.io/fig/)
|
||||
If you're looking contribute to [Fig](http://www.fig.sh/)
|
||||
but you're new to the project or maybe even to Python, here are the steps
|
||||
that should get you started.
|
||||
|
||||
@@ -90,4 +90,4 @@ The easiest way to do this is to use the `--signoff` flag when committing. E.g.:
|
||||
|
||||
5. Publish GitHub release, creating tag
|
||||
|
||||
|
||||
6. Update website with `script/deploy-docs`
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -176,7 +176,7 @@
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2014 Orchard Laboratories Ltd.
|
||||
Copyright 2014 Docker, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
4
MAINTAINERS
Normal file
4
MAINTAINERS
Normal file
@@ -0,0 +1,4 @@
|
||||
Aanand Prasad <aanand.prasad@gmail.com> (@aanand)
|
||||
Ben Firshman <ben@firshman.co.uk> (@bfirsh)
|
||||
Chris Corbyn <chris@w3style.co.uk> (@d11wtq)
|
||||
Nathan LeClaire <nathan.leclaire@gmail.com> (@nathanleclaire)
|
||||
@@ -46,4 +46,4 @@ Fig is a project from [Orchard](https://orchardup.com), a Docker hosting service
|
||||
Installation and documentation
|
||||
------------------------------
|
||||
|
||||
Full documentation is available on [Fig's website](http://orchardup.github.io/fig/).
|
||||
Full documentation is available on [Fig's website](http://www.fig.sh/).
|
||||
|
||||
1
docs/CNAME
Normal file
1
docs/CNAME
Normal file
@@ -0,0 +1 @@
|
||||
www.fig.sh
|
||||
@@ -7,6 +7,7 @@
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css?{{ site.time | date:'%Y%m%d%U%H%N%S' }}">
|
||||
<link rel="canonical" href="http://www.fig.sh{% if page.url =="/index.html" %}/{% else %}{{ page.url }}{% endif %}">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
@@ -39,7 +39,7 @@ Simple enough. Finally, this is all tied together with a file called `fig.yml`.
|
||||
links:
|
||||
- db
|
||||
|
||||
See the [`fig.yml` reference](http://orchardup.github.io/fig/yml.html) for more information on how it works.
|
||||
See the [`fig.yml` reference](yml.html) for more information on how it works.
|
||||
|
||||
We can now start a Django project using `fig run`:
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ title: Installing Fig
|
||||
Installing Fig
|
||||
==============
|
||||
|
||||
First, install Docker version 1.0.0. If you're on OS X, you can use [docker-osx](https://github.com/noplay/docker-osx):
|
||||
First, install Docker version 1.0 or greater. If you're on OS X, you can use [docker-osx](https://github.com/noplay/docker-osx):
|
||||
|
||||
$ curl https://raw.githubusercontent.com/noplay/docker-osx/1.0.0/docker-osx > /usr/local/bin/docker-osx
|
||||
$ curl https://raw.githubusercontent.com/noplay/docker-osx/1.1.1/docker-osx > /usr/local/bin/docker-osx
|
||||
$ chmod +x /usr/local/bin/docker-osx
|
||||
$ docker-osx shell
|
||||
|
||||
@@ -16,12 +16,12 @@ Docker has guides for [Ubuntu](http://docs.docker.io/en/latest/installation/ubun
|
||||
|
||||
Next, install Fig. On OS X:
|
||||
|
||||
$ curl -L https://github.com/orchardup/fig/releases/download/0.5.1/darwin > /usr/local/bin/fig
|
||||
$ curl -L https://github.com/orchardup/fig/releases/download/0.5.2/darwin > /usr/local/bin/fig
|
||||
$ chmod +x /usr/local/bin/fig
|
||||
|
||||
On 64-bit Linux:
|
||||
|
||||
$ curl -L https://github.com/orchardup/fig/releases/download/0.5.1/linux > /usr/local/bin/fig
|
||||
$ curl -L https://github.com/orchardup/fig/releases/download/0.5.2/linux > /usr/local/bin/fig
|
||||
$ chmod +x /usr/local/bin/fig
|
||||
|
||||
Fig is also available as a Python package if you're on another platform (or if you prefer that sort of thing):
|
||||
|
||||
29
docs/yml.md
29
docs/yml.md
@@ -76,6 +76,8 @@ expose:
|
||||
|
||||
Mount paths as volumes, optionally specifying a path on the host machine (`HOST:CONTAINER`).
|
||||
|
||||
Note: Mapping local volumes is currently unsupported on boot2docker. We recommend you use [docker-osx](https://github.com/noplay/docker-osx) if want to map local volumes.
|
||||
|
||||
```
|
||||
volumes:
|
||||
- /var/lib/mysql
|
||||
@@ -118,3 +120,30 @@ net: "none"
|
||||
net: "container:[name or id]"
|
||||
net: "host"
|
||||
```
|
||||
|
||||
### dns
|
||||
|
||||
Custom DNS servers. Can be a single value or a list.
|
||||
|
||||
```
|
||||
dns: 8.8.8.8
|
||||
dns:
|
||||
- 8.8.8.8
|
||||
- 9.9.9.9
|
||||
```
|
||||
|
||||
### working\_dir, entrypoint, user, hostname, domainname, mem\_limit, privileged
|
||||
|
||||
Each of these is a single value, analogous to its [docker run](https://docs.docker.com/reference/run/) counterpart.
|
||||
|
||||
```
|
||||
working_dir: /code
|
||||
entrypoint: /code/entrypoint.sh
|
||||
user: postgresql
|
||||
|
||||
hostname: foo
|
||||
domainname: foo.com
|
||||
|
||||
mem_limit: 1000000000
|
||||
privileged: true
|
||||
```
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from .service import Service
|
||||
from .service import Service # noqa:flake8
|
||||
|
||||
__version__ = '0.5.1'
|
||||
__version__ = '0.5.2'
|
||||
|
||||
@@ -8,7 +8,6 @@ import os
|
||||
import re
|
||||
import yaml
|
||||
from ..packages import six
|
||||
import sys
|
||||
|
||||
from ..project import Project
|
||||
from ..service import ConfigError
|
||||
@@ -19,6 +18,7 @@ from . import errors
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Command(DocoptCommand):
|
||||
base_dir = '.'
|
||||
|
||||
|
||||
@@ -24,16 +24,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
console_handler = logging.StreamHandler(stream=sys.stderr)
|
||||
console_handler.setFormatter(logging.Formatter())
|
||||
console_handler.setLevel(logging.INFO)
|
||||
root_logger = logging.getLogger()
|
||||
root_logger.addHandler(console_handler)
|
||||
root_logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Disable requests logging
|
||||
logging.getLogger("requests").propagate = False
|
||||
|
||||
setup_logging()
|
||||
try:
|
||||
command = TopLevelCommand()
|
||||
command.sys_dispatch()
|
||||
@@ -56,6 +47,18 @@ def main():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def setup_logging():
|
||||
console_handler = logging.StreamHandler(sys.stderr)
|
||||
console_handler.setFormatter(logging.Formatter())
|
||||
console_handler.setLevel(logging.INFO)
|
||||
root_logger = logging.getLogger()
|
||||
root_logger.addHandler(console_handler)
|
||||
root_logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Disable requests logging
|
||||
logging.getLogger("requests").propagate = False
|
||||
|
||||
|
||||
# stolen from docopt master
|
||||
def parse_doc_section(name, source):
|
||||
pattern = re.compile('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)',
|
||||
@@ -103,9 +106,13 @@ class TopLevelCommand(Command):
|
||||
e.g. `figtest_db`. If you change a service's `Dockerfile` or the
|
||||
contents of its build directory, you can run `fig build` to rebuild it.
|
||||
|
||||
Usage: build [SERVICE...]
|
||||
Usage: build [options] [SERVICE...]
|
||||
|
||||
Options:
|
||||
--no-cache Do not use cache when building the image.
|
||||
"""
|
||||
self.project.build(service_names=options['SERVICE'])
|
||||
no_cache = bool(options.get('--no-cache', False))
|
||||
self.project.build(service_names=options['SERVICE'], no_cache=no_cache)
|
||||
|
||||
def help(self, options):
|
||||
"""
|
||||
@@ -274,13 +281,13 @@ class TopLevelCommand(Command):
|
||||
try:
|
||||
num = int(num)
|
||||
except ValueError:
|
||||
raise UserError('Number of containers for service "%s" is not a number' % service)
|
||||
raise UserError('Number of containers for service "%s" is not a '
|
||||
'number' % service_name)
|
||||
try:
|
||||
self.project.get_service(service_name).scale(num)
|
||||
except CannotBeScaledError:
|
||||
raise UserError('Service "%s" cannot be scaled because it specifies a port on the host. If multiple containers for this service were created, the port would clash.\n\nRemove the ":" from the port definition in fig.yml so Docker can choose a random port for each container.' % service_name)
|
||||
|
||||
|
||||
def start(self, options):
|
||||
"""
|
||||
Start existing containers.
|
||||
@@ -350,5 +357,6 @@ class TopLevelCommand(Command):
|
||||
print("Gracefully stopping... (press Ctrl+C again to force)")
|
||||
self.project.stop(service_names=service_names)
|
||||
|
||||
|
||||
def list_containers(containers):
|
||||
return ", ".join(c.name for c in containers)
|
||||
|
||||
@@ -65,11 +65,11 @@ def prettydate(d):
|
||||
elif s < 120:
|
||||
return '1 minute ago'
|
||||
elif s < 3600:
|
||||
return '{0} minutes ago'.format(s/60)
|
||||
return '{0} minutes ago'.format(s / 60)
|
||||
elif s < 7200:
|
||||
return '1 hour ago'
|
||||
else:
|
||||
return '{0} hours ago'.format(s/3600)
|
||||
return '{0} hours ago'.format(s / 3600)
|
||||
|
||||
|
||||
def mkdir(path, permissions=0o700):
|
||||
@@ -103,8 +103,8 @@ def split_buffer(reader, separator):
|
||||
index = buffered.find(separator)
|
||||
if index == -1:
|
||||
break
|
||||
yield buffered[:index+1]
|
||||
buffered = buffered[index+1:]
|
||||
yield buffered[:index + 1]
|
||||
buffered = buffered[index + 1:]
|
||||
|
||||
if len(buffered) > 0:
|
||||
yield buffered
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
|
||||
|
||||
class Container(object):
|
||||
"""
|
||||
Represents a Docker container, constructed from the output of
|
||||
|
||||
@@ -38,6 +38,7 @@ def sort_service_dicts(services):
|
||||
|
||||
return sorted_services
|
||||
|
||||
|
||||
class Project(object):
|
||||
"""
|
||||
A collection of services.
|
||||
@@ -154,10 +155,10 @@ class Project(object):
|
||||
for service in reversed(self.get_services(service_names)):
|
||||
service.kill(**options)
|
||||
|
||||
def build(self, service_names=None, **options):
|
||||
def build(self, service_names=None, no_cache=False):
|
||||
for service in self.get_services(service_names):
|
||||
if service.can_be_built():
|
||||
service.build(**options)
|
||||
service.build(no_cache)
|
||||
else:
|
||||
log.info('%s uses an image, skipping' % service.name)
|
||||
|
||||
@@ -216,6 +217,6 @@ class ConfigurationError(Exception):
|
||||
def __str__(self):
|
||||
return self.msg
|
||||
|
||||
|
||||
class DependencyError(ConfigurationError):
|
||||
pass
|
||||
|
||||
|
||||
@@ -132,7 +132,6 @@ class Service(object):
|
||||
|
||||
self.remove_stopped()
|
||||
|
||||
|
||||
def remove_stopped(self, **options):
|
||||
for c in self.containers(stopped=True):
|
||||
if not c.is_running:
|
||||
@@ -212,7 +211,7 @@ class Service(object):
|
||||
log.info("Starting %s..." % container.name)
|
||||
return self.start_container(container, **options)
|
||||
|
||||
def start_container(self, container=None, intermediate_container=None,**override_options):
|
||||
def start_container(self, container=None, intermediate_container=None, **override_options):
|
||||
if container is None:
|
||||
container = self.create_container(**override_options)
|
||||
|
||||
@@ -239,6 +238,7 @@ class Service(object):
|
||||
|
||||
privileged = options.get('privileged', False)
|
||||
net = options.get('net', 'bridge')
|
||||
dns = options.get('dns', None)
|
||||
|
||||
container.start(
|
||||
links=self._get_links(link_to_self=override_options.get('one_off', False)),
|
||||
@@ -247,6 +247,7 @@ class Service(object):
|
||||
volumes_from=self._get_volumes_from(intermediate_container),
|
||||
privileged=privileged,
|
||||
network_mode=net,
|
||||
dns=dns,
|
||||
)
|
||||
return container
|
||||
|
||||
@@ -340,31 +341,29 @@ class Service(object):
|
||||
if 'environment' in container_options:
|
||||
if isinstance(container_options['environment'], list):
|
||||
container_options['environment'] = dict(split_env(e) for e in container_options['environment'])
|
||||
container_options['environment'] = dict(resolve_env(k,v) for k,v in container_options['environment'].iteritems())
|
||||
container_options['environment'] = dict(resolve_env(k, v) for k, v in container_options['environment'].iteritems())
|
||||
|
||||
if self.can_be_built():
|
||||
if len(self.client.images(name=self._build_tag_name())) == 0:
|
||||
self.build()
|
||||
container_options['image'] = self._build_tag_name()
|
||||
|
||||
# Priviliged is only required for starting containers, not for creating them
|
||||
if 'privileged' in container_options:
|
||||
del container_options['privileged']
|
||||
|
||||
# net is only required for starting containers, not for creating them
|
||||
if 'net' in container_options:
|
||||
del container_options['net']
|
||||
# Delete options which are only used when starting
|
||||
for key in ['privileged', 'net', 'dns']:
|
||||
if key in container_options:
|
||||
del container_options[key]
|
||||
|
||||
return container_options
|
||||
|
||||
def build(self):
|
||||
def build(self, no_cache=False):
|
||||
log.info('Building %s...' % self.name)
|
||||
|
||||
build_output = self.client.build(
|
||||
self.options['build'],
|
||||
tag=self._build_tag_name(),
|
||||
stream=True,
|
||||
rm=True
|
||||
rm=True,
|
||||
nocache=no_cache,
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -459,13 +458,15 @@ def split_port(port):
|
||||
external_port = (external_ip,)
|
||||
return internal_port, external_port
|
||||
|
||||
|
||||
def split_env(env):
|
||||
if '=' in env:
|
||||
return env.split('=', 1)
|
||||
else:
|
||||
return env, None
|
||||
|
||||
def resolve_env(key,val):
|
||||
|
||||
def resolve_env(key, val):
|
||||
if val is not None:
|
||||
return key, val
|
||||
elif key in os.environ:
|
||||
|
||||
@@ -2,3 +2,4 @@ mock==1.0.1
|
||||
nose==1.3.0
|
||||
pyinstaller==2.1
|
||||
unittest2
|
||||
flake8
|
||||
|
||||
@@ -3,4 +3,4 @@ PyYAML==3.10
|
||||
requests==2.2.1
|
||||
texttable==0.8.1
|
||||
websocket-client==0.11.0
|
||||
dockerpty==0.2.1
|
||||
dockerpty==0.2.3
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
flake8 fig
|
||||
PYTHONIOENCODING=ascii nosetests $@
|
||||
|
||||
5
setup.py
5
setup.py
@@ -32,9 +32,8 @@ setup(
|
||||
name='fig',
|
||||
version=find_version("fig", "__init__.py"),
|
||||
description='Punctual, lightweight development environments using Docker',
|
||||
url='http://orchardup.github.io/fig/',
|
||||
author='Orchard Laboratories Ltd.',
|
||||
author_email='hello@orchardup.com',
|
||||
url='http://www.fig.sh/',
|
||||
author='Docker, Inc.',
|
||||
license='Apache License 2.0',
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
|
||||
2
tests/fixtures/simple-dockerfile/fig.yml
vendored
Normal file
2
tests/fixtures/simple-dockerfile/fig.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
simple:
|
||||
build: tests/fixtures/simple-dockerfile
|
||||
@@ -46,6 +46,22 @@ class CLITestCase(DockerClientTestCase):
|
||||
self.assertNotIn('multiplefigfiles_another_1', output)
|
||||
self.assertIn('multiplefigfiles_yetanother_1', output)
|
||||
|
||||
@patch('sys.stdout', new_callable=StringIO)
|
||||
def test_build_no_cache(self, mock_stdout):
|
||||
self.command.base_dir = 'tests/fixtures/simple-dockerfile'
|
||||
self.command.dispatch(['build', 'simple'], None)
|
||||
|
||||
mock_stdout.truncate(0)
|
||||
cache_indicator = 'Using cache'
|
||||
self.command.dispatch(['build', 'simple'], None)
|
||||
output = mock_stdout.getvalue()
|
||||
self.assertIn(cache_indicator, output)
|
||||
|
||||
mock_stdout.truncate(0)
|
||||
self.command.dispatch(['build', '--no-cache', 'simple'], None)
|
||||
output = mock_stdout.getvalue()
|
||||
self.assertNotIn(cache_indicator, output)
|
||||
|
||||
def test_up(self):
|
||||
self.command.dispatch(['up', '-d'], None)
|
||||
service = self.command.project.get_service('simple')
|
||||
@@ -193,3 +209,4 @@ class CLITestCase(DockerClientTestCase):
|
||||
self.command.scale({'SERVICE=NUM': ['simple=0', 'another=0']})
|
||||
self.assertEqual(len(project.get_service('simple').containers()), 0)
|
||||
self.assertEqual(len(project.get_service('another').containers()), 0)
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ class ServiceTest(DockerClientTestCase):
|
||||
def test_port_with_explicit_interface(self):
|
||||
service = self.create_service('web', ports=[
|
||||
'127.0.0.1:8001:8000',
|
||||
'0.0.0.0:9001:9000',
|
||||
'0.0.0.0:9001:9000/udp',
|
||||
])
|
||||
container = service.start_container().inspect()
|
||||
self.assertEqual(container['NetworkSettings']['Ports'], {
|
||||
@@ -270,7 +270,7 @@ class ServiceTest(DockerClientTestCase):
|
||||
'HostPort': '8001',
|
||||
},
|
||||
],
|
||||
'9000/tcp': [
|
||||
'9000/udp': [
|
||||
{
|
||||
'HostIp': '0.0.0.0',
|
||||
'HostPort': '9001',
|
||||
@@ -316,6 +316,16 @@ class ServiceTest(DockerClientTestCase):
|
||||
container = service.start_container().inspect()
|
||||
self.assertEqual(container['HostConfig']['NetworkMode'], 'host')
|
||||
|
||||
def test_dns_single_value(self):
|
||||
service = self.create_service('web', dns='8.8.8.8')
|
||||
container = service.start_container().inspect()
|
||||
self.assertEqual(container['HostConfig']['Dns'], ['8.8.8.8'])
|
||||
|
||||
def test_dns_list(self):
|
||||
service = self.create_service('web', dns=['8.8.8.8', '9.9.9.9'])
|
||||
container = service.start_container().inspect()
|
||||
self.assertEqual(container['HostConfig']['Dns'], ['8.8.8.8', '9.9.9.9'])
|
||||
|
||||
def test_working_dir_param(self):
|
||||
service = self.create_service('container', working_dir='/working/dir/sample')
|
||||
container = service.create_container().inspect()
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
import os
|
||||
from .. import unittest
|
||||
|
||||
from fig.cli import main
|
||||
from fig.cli.main import TopLevelCommand
|
||||
from fig.packages.six import StringIO
|
||||
import os
|
||||
|
||||
|
||||
class CLITestCase(unittest.TestCase):
|
||||
def test_default_project_name(self):
|
||||
@@ -35,3 +39,8 @@ class CLITestCase(unittest.TestCase):
|
||||
command = TopLevelCommand()
|
||||
with self.assertRaises(SystemExit):
|
||||
command.dispatch(['-h'], None)
|
||||
|
||||
def test_setup_logging(self):
|
||||
main.setup_logging()
|
||||
self.assertEqual(logging.getLogger().level, logging.DEBUG)
|
||||
self.assertEqual(logging.getLogger('requests').propagate, False)
|
||||
|
||||
@@ -33,6 +33,10 @@ class ServiceTest(unittest.TestCase):
|
||||
self.assertEqual(internal_port, "2000")
|
||||
self.assertEqual(external_port, ("127.0.0.1", "1000"))
|
||||
|
||||
internal_port, external_port = split_port("127.0.0.1:1000:2000/udp")
|
||||
self.assertEqual(internal_port, "2000/udp")
|
||||
self.assertEqual(external_port, ("127.0.0.1", "1000"))
|
||||
|
||||
internal_port, external_port = split_port("127.0.0.1::2000")
|
||||
self.assertEqual(internal_port, "2000")
|
||||
self.assertEqual(external_port, ("127.0.0.1",))
|
||||
|
||||
13
tox.ini
13
tox.ini
@@ -2,7 +2,14 @@
|
||||
envlist = py26,py27,py32,py33,pypy
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
-rrequirements.txt
|
||||
-rrequirements-dev.txt
|
||||
commands =
|
||||
pip install -e {toxinidir}
|
||||
pip install -e {toxinidir}[test]
|
||||
python setup.py test
|
||||
nosetests {posargs}
|
||||
flake8 fig
|
||||
|
||||
[flake8]
|
||||
# ignore line-length for now
|
||||
ignore = E501,E203
|
||||
exclude = fig/packages/
|
||||
|
||||
Reference in New Issue
Block a user