class GithubTest(EnhancedTestCase):
    """ small test for The github package
    This should not be to much, since there is an hourly limit of request
    for non authenticated users of 50"""
    def setUp(self):
        """setup"""
        super(GithubTest, self).setUp()
        github_user = '******'
        github_token = fetch_github_token(github_user)
        if github_token is None:
            self.ghfs = None
        else:
            self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH,
                                 github_user, None, github_token)

    def test_walk(self):
        """test the gitubfs walk function"""
        # TODO: this will not work when rate limited, so we should have a test account token here
        if self.ghfs is not None:
            try:
                expected = [
                    (None, ['a_directory', 'second_dir'], ['README.md']),
                    ('a_directory', ['a_subdirectory'], ['a_file.txt']),
                    ('a_directory/a_subdirectory', [], ['a_file.txt']),
                    ('second_dir', [], ['a_file.txt'])
                ]
                self.assertEquals([x for x in self.ghfs.walk(None)], expected)
            except IOError:
                pass
        else:
            print "Skipping test_walk, no GitHub token available?"

    def test_read_api(self):
        """Test the githubfs read function"""
        if self.ghfs is not None:
            try:
                self.assertEquals(
                    self.ghfs.read("a_directory/a_file.txt").strip(),
                    "this is a line of text")
            except IOError:
                pass
        else:
            print "Skipping test_read_api, no GitHub token available?"

    def test_read(self):
        """Test the githubfs read function without using the api"""
        if self.ghfs is not None:
            try:
                fp = self.ghfs.read("a_directory/a_file.txt", api=False)
                self.assertEquals(
                    open(fp, 'r').read().strip(), "this is a line of text")
                os.remove(fp)
            except (IOError, OSError):
                pass
        else:
            print "Skipping test_read, no GitHub token available?"
class GithubTest(EnhancedTestCase):
    """ small test for The github package
    This should not be to much, since there is an hourly limit of request
    for non authenticated users of 50"""

    def setUp(self):
        """setup"""
        super(GithubTest, self).setUp()
        github_user = '******'
        github_token = fetch_github_token(github_user)
        if github_token is None:
            self.ghfs = None
        else:
            self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH, github_user, None, github_token)

    def test_walk(self):
        """test the gitubfs walk function"""
        # TODO: this will not work when rate limited, so we should have a test account token here
        if self.ghfs is not None:
            try:
                expected = [(None, ['a_directory', 'second_dir'], ['README.md']),
                            ('a_directory', ['a_subdirectory'], ['a_file.txt']), ('a_directory/a_subdirectory', [],
                            ['a_file.txt']), ('second_dir', [], ['a_file.txt'])]
                self.assertEquals([x for x in self.ghfs.walk(None)], expected)
            except IOError:
                pass
        else:
            print "Skipping test_walk, no GitHub token available?"

    def test_read_api(self):
        """Test the githubfs read function"""
        if self.ghfs is not None:
            try:
                self.assertEquals(self.ghfs.read("a_directory/a_file.txt").strip(), "this is a line of text")
            except IOError:
                pass
        else:
            print "Skipping test_read_api, no GitHub token available?"

    def test_read(self):
        """Test the githubfs read function without using the api"""
        if self.ghfs is not None:
            try:
                fp = self.ghfs.read("a_directory/a_file.txt", api=False)
                self.assertEquals(open(fp, 'r').read().strip(), "this is a line of text")
                os.remove(fp)
            except (IOError, OSError):
                pass
        else:
            print "Skipping test_read, no GitHub token available?"
Beispiel #3
0
class GithubTest(TestCase):
    """ small test for The github package
    This should not be to much, since there is an hourly limit of request
    for non authenticated users of 50"""

    def setUp(self):
        """setup"""
        self.cwd = os.getcwd()
        self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH, GITHUB_LOGIN, GITHUB_PASSWORD, GITHUB_TOKEN)

    def test_walk(self):
        """test the gitubfs walk function"""
        # TODO: this will not work when rate limited, so we should have a test account token here
        try:
            self.assertEquals([x for x in self.ghfs.walk(None)], [(None, ['a_directory', 'second_dir'], ['README.md']),
                     ('a_directory', ['a_subdirectory'], ['a_file.txt']), ('a_directory/a_subdirectory', [],
                     ['a_file.txt']), ('second_dir', [], ['a_file.txt'])]
                )
        except IOError:
            pass

    def test_read_api(self):
        """Test the githubfs read function"""
        try:
            self.assertEquals(self.ghfs.read("a_directory/a_file.txt"), "this is a line of text\n")
        except IOError:
            pass

    def test_read(self):
        """Test the githubfs read function without using the api"""
        try:
            fp = self.ghfs.read("a_directory/a_file.txt", api=False)
            self.assertEquals(open(fp, 'r').read(), "this is a line of text\n")
            os.remove(fp)
        except (IOError, OSError):
            pass

    def tearDown(self):
        """cleanup"""
        os.chdir(self.cwd)
Beispiel #4
0
class GithubTest(TestCase):
    """ small test for The github package
    This should not be to much, since there is an hourly limit of request
    for non authenticated users of 50"""

    def setUp(self):
        """setup"""
        self.cwd = os.getcwd()
        self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH, GITHUB_LOGIN, GITHUB_PASSWORD, GITHUB_TOKEN)

    def test_walk(self):
        """test the gitubfs walk function"""
        # TODO: this will not work when rate limited, so we should have a test account token here
        try:
            self.assertEquals([x for x in self.ghfs.walk(None)], [(None, ['a_directory', 'second_dir'], ['README.md']),
                     ('a_directory', ['a_subdirectory'], ['a_file.txt']), ('a_directory/a_subdirectory', [],
                     ['a_file.txt']), ('second_dir', [], ['a_file.txt'])]
                )
        except IOError:
            pass

    def test_read_api(self):
        """Test the githubfs read function"""
        try:
            self.assertEquals(self.ghfs.read("a_directory/a_file.txt"), "this is a line of text\n")
        except IOError:
            pass

    def test_read(self):
        """Test the githubfs read function without using the api"""
        try:
            fp = self.ghfs.read("a_directory/a_file.txt", api=False)
            self.assertEquals(open(fp, 'r').read(), "this is a line of text\n")
            os.remove(fp)
        except (IOError, OSError):
            pass

    def tearDown(self):
        """cleanup"""
        os.chdir(self.cwd)
class GithubTest(EnhancedTestCase):
    """ small test for The github package
    This should not be to much, since there is an hourly limit of request
    for non authenticated users of 50"""

    def setUp(self):
        """setup"""
        super(GithubTest, self).setUp()
        github_user = GITHUB_TEST_ACCOUNT
        github_token = fetch_github_token(github_user)
        if github_token is None:
            self.ghfs = None
        else:
            self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH, github_user, None, github_token)

    def test_walk(self):
        """test the gitubfs walk function"""
        # TODO: this will not work when rate limited, so we should have a test account token here
        if self.ghfs is not None:
            try:
                expected = [(None, ['a_directory', 'second_dir'], ['README.md']),
                            ('a_directory', ['a_subdirectory'], ['a_file.txt']), ('a_directory/a_subdirectory', [],
                            ['a_file.txt']), ('second_dir', [], ['a_file.txt'])]
                self.assertEquals([x for x in self.ghfs.walk(None)], expected)
            except IOError:
                pass
        else:
            print "Skipping test_walk, no GitHub token available?"

    def test_read_api(self):
        """Test the githubfs read function"""
        if self.ghfs is not None:
            try:
                self.assertEquals(self.ghfs.read("a_directory/a_file.txt").strip(), "this is a line of text")
            except IOError:
                pass
        else:
            print "Skipping test_read_api, no GitHub token available?"

    def test_read(self):
        """Test the githubfs read function without using the api"""
        if self.ghfs is not None:
            try:
                fp = self.ghfs.read("a_directory/a_file.txt", api=False)
                self.assertEquals(open(fp, 'r').read().strip(), "this is a line of text")
                os.remove(fp)
            except (IOError, OSError):
                pass
        else:
            print "Skipping test_read, no GitHub token available?"

    def test_fetch_easyconfigs_from_pr(self):
        """Test fetch_easyconfigs_from_pr function."""
        tmpdir = tempfile.mkdtemp()
        # PR for ictce/6.2.5, see https://github.com/hpcugent/easybuild-easyconfigs/pull/726/files
        all_ecs = ['gzip-1.6-ictce-6.2.5.eb', 'icc-2013_sp1.2.144.eb', 'ictce-6.2.5.eb', 'ifort-2013_sp1.2.144.eb',
                   'imkl-11.1.2.144.eb', 'impi-4.1.3.049.eb']
        ec_files = fetch_easyconfigs_from_pr(726, path=tmpdir, github_user=GITHUB_TEST_ACCOUNT)
        self.assertEqual(all_ecs, sorted([os.path.basename(f) for f in ec_files]))
        self.assertEqual(all_ecs, sorted(os.listdir(tmpdir)))
        shutil.rmtree(tmpdir)

        # PR for EasyBuild v1.13.0 release (250+ commits, 218 files changed)
        err_msg = "PR #897 contains more than .* commits, can't obtain last commit"
        self.assertErrorRegex(EasyBuildError, err_msg, fetch_easyconfigs_from_pr, 897, github_user=GITHUB_TEST_ACCOUNT)
Beispiel #6
0
class GithubTest(EnhancedTestCase):
    """ small test for The github package
    This should not be to much, since there is an hourly limit of request
    for non authenticated users of 50"""

    def setUp(self):
        """setup"""
        super(GithubTest, self).setUp()
        self.github_token = fetch_github_token(GITHUB_TEST_ACCOUNT)
        if self.github_token is None:
            self.ghfs = None
        else:
            self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH, GITHUB_TEST_ACCOUNT, None, self.github_token)

    def test_walk(self):
        """test the gitubfs walk function"""
        if self.github_token is None:
            print "Skipping test_walk, no GitHub token available?"
            return

        try:
            expected = [(None, ['a_directory', 'second_dir'], ['README.md']),
                        ('a_directory', ['a_subdirectory'], ['a_file.txt']), ('a_directory/a_subdirectory', [],
                        ['a_file.txt']), ('second_dir', [], ['a_file.txt'])]
            self.assertEquals([x for x in self.ghfs.walk(None)], expected)
        except IOError:
            pass

    def test_read_api(self):
        """Test the githubfs read function"""
        if self.github_token is None:
            print "Skipping test_read_api, no GitHub token available?"
            return

        try:
            self.assertEquals(self.ghfs.read("a_directory/a_file.txt").strip(), "this is a line of text")
        except IOError:
            pass

    def test_read(self):
        """Test the githubfs read function without using the api"""
        if self.github_token is None:
            print "Skipping test_read, no GitHub token available?"
            return

        try:
            fp = self.ghfs.read("a_directory/a_file.txt", api=False)
            self.assertEquals(open(fp, 'r').read().strip(), "this is a line of text")
            os.remove(fp)
        except (IOError, OSError):
            pass

    def test_fetch_easyconfigs_from_pr(self):
        """Test fetch_easyconfigs_from_pr function."""
        if self.github_token is None:
            print "Skipping test_fetch_easyconfigs_from_pr, no GitHub token available?"
            return

        tmpdir = tempfile.mkdtemp()
        # PR for ictce/6.2.5, see https://github.com/hpcugent/easybuild-easyconfigs/pull/726/files
        all_ecs = ['gzip-1.6-ictce-6.2.5.eb', 'icc-2013_sp1.2.144.eb', 'ictce-6.2.5.eb', 'ifort-2013_sp1.2.144.eb',
                   'imkl-11.1.2.144.eb', 'impi-4.1.3.049.eb']
        try:
            ec_files = fetch_easyconfigs_from_pr(726, path=tmpdir, github_user=GITHUB_TEST_ACCOUNT)
            self.assertEqual(all_ecs, sorted([os.path.basename(f) for f in ec_files]))
            self.assertEqual(all_ecs, sorted(os.listdir(tmpdir)))

            # PR for EasyBuild v1.13.0 release (250+ commits, 218 files changed)
            err_msg = "PR #897 contains more than .* commits, can't obtain last commit"
            self.assertErrorRegex(EasyBuildError, err_msg, fetch_easyconfigs_from_pr, 897, github_user=GITHUB_TEST_ACCOUNT)

        except URLError, err:
            print "Ignoring URLError '%s' in test_fetch_easyconfigs_from_pr" % err

        shutil.rmtree(tmpdir)