Skip to content

Commit

Permalink
Minimize changes to increase merge likelihood
Browse files Browse the repository at this point in the history
  • Loading branch information
invisibleroads committed Jul 31, 2014
1 parent d47b360 commit c1ef71c
Showing 1 changed file with 50 additions and 32 deletions.
82 changes: 50 additions & 32 deletions pyramid/tests/test_scripts/test_pcreate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import unittest
from os import getcwd
from os.path import abspath, join, normpath

class TestPCreateCommand(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -52,150 +50,170 @@ def test_no_project_name(self):
self.assertTrue(out.startswith('You must provide a project name'))

def test_unknown_scaffold_name(self):
cmd = self._makeOne('-s', 'dummyXX', 'Distro')
cmd = self._makeOne('-s', 'dummyXX', 'distro')
result = cmd.run()
self.assertEqual(result, 2)
out = self.out_.getvalue()
self.assertTrue(out.startswith('Unavailable scaffolds'))

def test_known_scaffold_single_rendered(self):
import os
cmd = self._makeOne('-s', 'dummy', 'Distro')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.1')
cmd.pyramid_dist = DummyDist("0.1")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.output_dir, normpath(join(getcwd(), 'Distro')))
scaffold.output_dir,
os.path.normpath(os.path.join(os.getcwd(), 'Distro'))
)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.1', 'pyramid_docs_branch': '0.1-branch'})
'pyramid_version': '0.1', 'pyramid_docs_branch':'0.1-branch'})

def test_scaffold_with_hyphen_in_project_name(self):
import os
cmd = self._makeOne('-s', 'dummy', 'Distro-')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.1')
cmd.pyramid_dist = DummyDist("0.1")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.output_dir, normpath(join(getcwd(), 'Distro-')))
scaffold.output_dir,
os.path.normpath(os.path.join(os.getcwd(), 'Distro-'))
)
self.assertEqual(
scaffold.vars,
{'project': 'Distro-', 'egg': 'Distro_', 'package': 'distro_',
'pyramid_version': '0.1', 'pyramid_docs_branch': '0.1-branch'})
'pyramid_version': '0.1', 'pyramid_docs_branch':'0.1-branch'})

def test_known_scaffold_absolute_path(self):
path = abspath('Distro')
import os
path = os.path.abspath('Distro')
cmd = self._makeOne('-s', 'dummy', path)
cmd.pyramid_dist = DummyDist('0.1')
cmd.pyramid_dist = DummyDist("0.1")
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.1')
cmd.pyramid_dist = DummyDist("0.1")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.output_dir, normpath(join(getcwd(), 'Distro')))
scaffold.output_dir,
os.path.normpath(os.path.join(os.getcwd(), 'Distro'))
)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.1', 'pyramid_docs_branch': '0.1-branch'})
'pyramid_version': '0.1', 'pyramid_docs_branch':'0.1-branch'})

def test_known_scaffold_multiple_rendered(self):
import os
cmd = self._makeOne('-s', 'dummy1', '-s', 'dummy2', 'Distro')
scaffold1 = DummyScaffold('dummy1')
scaffold2 = DummyScaffold('dummy2')
cmd.scaffolds = [scaffold1, scaffold2]
cmd.pyramid_dist = DummyDist('0.1')
cmd.pyramid_dist = DummyDist("0.1")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold1.output_dir, normpath(join(getcwd(), 'Distro')))
scaffold1.output_dir,
os.path.normpath(os.path.join(os.getcwd(), 'Distro'))
)
self.assertEqual(
scaffold1.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.1', 'pyramid_docs_branch': '0.1-branch'})
'pyramid_version': '0.1', 'pyramid_docs_branch':'0.1-branch'})
self.assertEqual(
scaffold2.output_dir, normpath(join(getcwd(), 'Distro')))
scaffold2.output_dir,
os.path.normpath(os.path.join(os.getcwd(), 'Distro'))
)
self.assertEqual(
scaffold2.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.1', 'pyramid_docs_branch': '0.1-branch'})
'pyramid_version': '0.1', 'pyramid_docs_branch':'0.1-branch'})

def test_known_scaffold_with_path_as_project_target_rendered(self):
import os
cmd = self._makeOne('-s', 'dummy', '/tmp/foo/Distro/')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.1')
cmd.pyramid_dist = DummyDist("0.1")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.output_dir, normpath(join(getcwd(), '/tmp/foo/Distro')))
scaffold.output_dir,
os.path.normpath(os.path.join(os.getcwd(), '/tmp/foo/Distro'))
)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.1', 'pyramid_docs_branch': '0.1-branch'})
'pyramid_version': '0.1', 'pyramid_docs_branch':'0.1-branch'})


def test_scaffold_with_prod_pyramid_version(self):
cmd = self._makeOne('-s', 'dummy', 'Distro')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.2')
cmd.pyramid_dist = DummyDist("0.2")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.2', 'pyramid_docs_branch': '0.2-branch'})
'pyramid_version': '0.2', 'pyramid_docs_branch':'0.2-branch'})

def test_scaffold_with_prod_pyramid_long_version(self):
cmd = self._makeOne('-s', 'dummy', 'Distro')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.2.1')
cmd.pyramid_dist = DummyDist("0.2.1")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.2.1', 'pyramid_docs_branch': '0.2-branch'})
'pyramid_version': '0.2.1', 'pyramid_docs_branch':'0.2-branch'})

def test_scaffold_with_prod_pyramid_unparsable_version(self):
cmd = self._makeOne('-s', 'dummy', 'Distro')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('abc')
cmd.pyramid_dist = DummyDist("abc")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': 'abc', 'pyramid_docs_branch': 'latest'})
'pyramid_version': 'abc', 'pyramid_docs_branch':'latest'})

def test_scaffold_with_dev_pyramid_version(self):
cmd = self._makeOne('-s', 'dummy', 'Distro')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.12dev')
cmd.pyramid_dist = DummyDist("0.12dev")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.12dev', 'pyramid_docs_branch': 'master'})
'pyramid_version': '0.12dev',
'pyramid_docs_branch': 'master'})

def test_scaffold_with_dev_pyramid_long_version(self):
cmd = self._makeOne('-s', 'dummy', 'Distro')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
cmd.pyramid_dist = DummyDist('0.10.1dev')
cmd.pyramid_dist = DummyDist("0.10.1dev")
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro',
'pyramid_version': '0.10.1dev', 'pyramid_docs_branch': 'master'})
'pyramid_version': '0.10.1dev',
'pyramid_docs_branch': 'master'})


class Test_main(unittest.TestCase):
Expand Down

0 comments on commit c1ef71c

Please sign in to comment.