Example #1
0
 def _deinit(self, owner):
     sys.argv = ['github',
                 'deinit',
                 self.name]
     if owner is not None:
         sys.argv += ['--owner=' + owner]
     cli.main_github()
     if os.path.exists(self.name):
         shutil.rmtree(self.name)
Example #2
0
 def _init(self, owner):
     sys.argv = ['github',
                 'init',
                 self.name,
                 '--description=' + self.description,
                 '--homepage=' + self.homepage,
                 '--license=' + self.license]
     if owner is not None:
         sys.argv += ['--owner=' + owner]
     cli.main_github()
Example #3
0
    def test_02(self):
        """Test `github fork`, `github issues` and `github issue` commands"""
        self._init(owner=self.owner)
        self._fork()
        self._clone()
        self._issue()

        old_stdout = sys.stdout
        new_stdout = StringIO()
        sys.stdout = new_stdout
        sys.argv = ['github',
                    'issues',
                    self.name]
        cli.main_github()
        sys.stdout = old_stdout
        self.assertIn("#1: Test commands", new_stdout.getvalue())
        old_stdout = sys.stdout
        new_stdout = StringIO()
        sys.stdout = new_stdout
        sys.argv = ['github',
                    'issues',
                    self.name,
                    '--assigned']
        cli.main_github()
        sys.stdout = old_stdout
        self.assertIn("#1: Test commands", new_stdout.getvalue())
        old_stdout = sys.stdout
        new_stdout = StringIO()
        sys.stdout = new_stdout
        sys.argv = ['github',
                    'issue',
                    self.name,
                    '1']
        cli.main_github()
        sys.stdout = old_stdout
        self.assertEqual("Test commands #1\n\nThis is a fake issue that is used to test commands related to issues.\r\nIt must contains at least 2 lines.\n", new_stdout.getvalue())

        # self._deinit()
        # self._deinit(owner=owner)

    # def test_03(self, branch="feature"):
    #     """Test `github fork`, `github feature`, `github start` and `github end` commands"""
    #     sys.argv = ['github',
    #                 'fork',
    #                 'devops-tools',
    #                 '--owner=' + self.owner]
    #     cli.main_github()
    #     sys.argv = ['github',
    #                 'clone',
    #                 'devops-tools']
    #     cli.main_github()
    #     sys.argv = ['github',
    #                 branch,
    #                 'devops-tools',
    #                 '--issue=2']
    #     cli.main_github()
    #     sys.argv = ['github',
    #                 'end',
    #                 'devops-tools']
    #     cli.main_github()
    #     sys.argv = ['github',
    #                 'start',
    #                 'devops-tools']
    #     cli.main_github()
    #     subprocess.call(['git', '-C', 'devops-tools', 'commit', '--allow-empty', '-m"An empty commit for testing pull requests"'])
    #     subprocess.call(['git', '-C', 'devops-tools', 'push'])
    #     sys.argv = ['github',
    #                 'end',
    #                 'devops-tools',
    #                 '--suggest']
    #     cli.main_github()
    #     sys.argv = ['github',
    #                 'deinit',
    #                 'devops-tools']
    #     cli.main_github()
    #     shutil.rmtree('devops-tools')

    # def test_04(self):
    #     """Test `github fork`, `github hotfix`, `github start` and `github end` commands"""
    #     self.test_03(branch="hotfix")
Example #4
0
 def _clone(self):
     sys.argv = ['github',
         'clone',
         self.name]
     cli.main_github()
Example #5
0
 def _fork(self):
     sys.argv = ['github',
                 'fork',
                 self.name,
                 '--owner=' + self.owner]
     cli.main_github()