Пример #1
0
    def test_should_run_all_tasks_until_finished(self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  True,
                                  'github':
                                  False,
                                  'git':
                                  False,
                                  'svn':
                                  False,
                                  '--virtualenv':
                                  'virtualenv'
                              })
        mock_reactor = mock()
        mock_task_1 = mock()
        mock_task_2 = mock()
        when(pyb_init.reactor).for_local_initialization().thenReturn(
            mock_reactor)
        when(mock_reactor).get_tasks().thenReturn([mock_task_1, mock_task_2])

        entry_point()

        verify(mock_task_1).execute()
        verify(mock_task_2).execute()
Пример #2
0
    def test_should_invoke_docopt_with_version_and_docstring(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': True,
                                                    'github': False,
                                                    'git': False,
                                                    'svn': False,
                                                    '--virtualenv': 'virtualenv'})

        entry_point()

        verify(pyb_init).docopt(doc=pyb_init.__doc__, version='${version}')
Пример #3
0
    def test_should_run_local_initialization_when_argument_is_given(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': True,
                                                    'github': False,
                                                    'git': False,
                                                    'svn': False,
                                                    '--virtualenv': 'virtualenv'})

        entry_point()

        verify(pyb_init.reactor).for_local_initialization()
Пример #4
0
    def test_should_configure_virtualenv_name(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': True,
                                                    'github': False,
                                                    'git': False,
                                                    'svn': False,
                                                    '--virtualenv': 'foobar'})

        entry_point()

        self.assertEqual(configuration['virtualenv_name'], 'foobar')
Пример #5
0
    def test_should_not_configure_system_site_packages_when_option_is_not_provided(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': True,
                                                    'github': False,
                                                    'git': False,
                                                    'svn': False,
                                                    '-s': False,
                                                    '--virtualenv': 'venv'})

        entry_point()

        self.assertFalse(configuration['virtualenv_use_system_site_packages'])
Пример #6
0
    def test_should_run_svn_checkout_when_argument_is_given(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': False,
                                                    'git': False,
                                                    'github': False,
                                                    'svn': True,
                                                    '<svn_url>': 'http://code/foo/bar',
                                                    '--virtualenv': 'virtualenv'})

        entry_point()

        verify(pyb_init.reactor).for_svn_checkout(
            svn_url='http://code/foo/bar')
Пример #7
0
    def test_should_run_github_initialization_when_argument_is_given(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': False,
                                                    'git': False,
                                                    'github': True,
                                                    'svn': False,
                                                    '<user>': 'coder1234',
                                                    '<project>': 'committer',
                                                    '--virtualenv': 'virtualenv'})

        entry_point()

        verify(pyb_init.reactor).for_github_clone(
            user='******', project='committer')
Пример #8
0
    def test_should_eat_exceptions_and_output_error_message_instead(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': True,
                                                    'github': False,
                                                    'git': False,
                                                    'svn': False,
                                                    '--virtualenv': 'foobar'})
        when(pyb_init.reactor).for_local_initialization().thenRaise(
            RuntimeError('too fat to fly'))
        when(pyb_init.logger).error(any_value()).thenReturn(None)

        entry_point()

        verify(pyb_init.logger).error('too fat to fly')
Пример #9
0
    def test_should_run_local_initialization_when_argument_is_given(self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  True,
                                  'github':
                                  False,
                                  'git':
                                  False,
                                  'svn':
                                  False,
                                  '--virtualenv':
                                  'virtualenv'
                              })

        entry_point()

        verify(pyb_init.reactor).for_local_initialization()
Пример #10
0
    def test_should_invoke_docopt_with_version_and_docstring(self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  True,
                                  'github':
                                  False,
                                  'git':
                                  False,
                                  'svn':
                                  False,
                                  '--virtualenv':
                                  'virtualenv'
                              })

        entry_point()

        verify(pyb_init).docopt(doc=pyb_init.__doc__, version='${version}')
Пример #11
0
    def test_should_configure_virtualenv_name(self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  True,
                                  'github':
                                  False,
                                  'git':
                                  False,
                                  'svn':
                                  False,
                                  '--virtualenv':
                                  'foobar'
                              })

        entry_point()

        self.assertEqual(configuration['virtualenv_name'], 'foobar')
Пример #12
0
    def test_should_run_all_tasks_until_finished(self):
        when(
            pyb_init).docopt(
                doc=any_value(
                ), version=any_value()).thenReturn({'local': True,
                                                    'github': False,
                                                    'git': False,
                                                    'svn': False,
                                                    '--virtualenv': 'virtualenv'})
        mock_reactor = mock()
        mock_task_1 = mock()
        mock_task_2 = mock()
        when(pyb_init.reactor).for_local_initialization().thenReturn(
            mock_reactor)
        when(mock_reactor).get_tasks().thenReturn([mock_task_1, mock_task_2])

        entry_point()

        verify(mock_task_1).execute()
        verify(mock_task_2).execute()
Пример #13
0
    def test_should_run_svn_checkout_when_argument_is_given(self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  False,
                                  'git':
                                  False,
                                  'github':
                                  False,
                                  'svn':
                                  True,
                                  '<svn_url>':
                                  'http://code/foo/bar',
                                  '--virtualenv':
                                  'virtualenv'
                              })

        entry_point()

        verify(
            pyb_init.reactor).for_svn_checkout(svn_url='http://code/foo/bar')
Пример #14
0
    def test_should_eat_exceptions_and_output_error_message_instead(self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  True,
                                  'github':
                                  False,
                                  'git':
                                  False,
                                  'svn':
                                  False,
                                  '--virtualenv':
                                  'foobar'
                              })
        when(pyb_init.reactor).for_local_initialization().thenRaise(
            RuntimeError('too fat to fly'))
        when(pyb_init.logger).error(any_value()).thenReturn(None)

        entry_point()

        verify(pyb_init.logger).error('too fat to fly')
Пример #15
0
    def test_should_not_configure_system_site_packages_when_option_is_not_provided(
            self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  True,
                                  'github':
                                  False,
                                  'git':
                                  False,
                                  'svn':
                                  False,
                                  '-s':
                                  False,
                                  '--virtualenv':
                                  'venv'
                              })

        entry_point()

        self.assertFalse(configuration['virtualenv_use_system_site_packages'])
Пример #16
0
    def test_should_run_github_initialization_when_argument_is_given(self):
        when(pyb_init).docopt(doc=any_value(),
                              version=any_value()).thenReturn({
                                  'local':
                                  False,
                                  'git':
                                  False,
                                  'github':
                                  True,
                                  'svn':
                                  False,
                                  '<user>':
                                  'coder1234',
                                  '<project>':
                                  'committer',
                                  '--virtualenv':
                                  'virtualenv'
                              })

        entry_point()

        verify(pyb_init.reactor).for_github_clone(user='******',
                                                  project='committer')