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)
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?"
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)
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(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)
options.branch = "develop" if not options.username: options.username = "******" if not options.repo: options.repo = "easybuild-easyconfigs" if not options.path: options.path = "easybuild/easyconfigs" if options.local: import os walk = os.walk join = os.path.join read = lambda ec_file: ec_file log.info('parsing easyconfigs from location %s' % options.path) else: fs = Githubfs(options.username, options.repo, options.branch) walk = Githubfs(options.username, options.repo, options.branch).walk join = fs.join read = lambda ec_file: fs.read(ec_file, api=False) log.info('parsing easyconfigs from user %s reponame %s' % (options.username, options.repo)) # configure EasyBuild, by parsing options eb_go = eboptions.parse_options(args=args) config.init(eb_go.options, eb_go.get_options_by_section('config')) config.init_build_options({'validate': False, 'external_modules_metadata': {}}) configs = [] names = []
options.branch = "develop" if not options.username: options.username = "******" if not options.repo: options.repo = "easybuild-easyconfigs" if not options.path: options.path = "easybuild/easyconfigs" if options.local: import os walk = os.walk join = os.path.join read = lambda ec_file : ec_file log.info('parsing easyconfigs from location %s' % options.path) else: fs = Githubfs(options.username, options.repo, options.branch) walk = Githubfs(options.username, options.repo, options.branch).walk join = fs.join read = lambda ec_file : fs.read(ec_file, api=False) log.info('parsing easyconfigs from user %s reponame %s' % (options.username, options.repo)) # configure EasyBuild, by parsing options eb_go = eboptions.parse_options(args=args) config.init(eb_go.options, eb_go.get_options_by_section('config')) config.init_build_options({'validate': False}) configs = [] names = []
# other options if not options.branch: options.branch = "develop" if not options.username: options.username = "******" if not options.repo: options.repo = "easybuild-easyconfigs" if not options.path: options.path = "easybuild/easyconfigs" if options.local: import os walk = os.walk join = os.path.join read = lambda file_: file_ else: fs = Githubfs(options.username, options.repo, options.branch) walk = Githubfs(options.username, options.repo, options.branch).walk join = fs.join read = lambda file_: fs.read(file_, api=False) log.info('parsing easyconfigs from user %s reponame %s' % (options.username, options.repo)) configs = [] names = [] # fs.walk yields the same results as os.walk, so should be interchangable # same for fs.join and os.path.join for root, subfolders, files in walk(options.path): if '.git' in subfolders:
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)
# other options if not options.branch: options.branch = "develop" if not options.username: options.username = "******" if not options.repo: options.repo = "easybuild-easyconfigs" if not options.path: options.path = "easybuild/easyconfigs" if options.local: import os walk = os.walk join = os.path.join read = lambda file_ : file_ else: fs = Githubfs(options.username, options.repo, options.branch) walk = Githubfs(options.username, options.repo, options.branch).walk join = fs.join read = lambda file_ : fs.read(file_, api=False) log.info('parsing easyconfigs from user %s reponame %s' % (options.username, options.repo)) configs = [] names = [] # fs.walk yields the same results as os.walk, so should be interchangable # same for fs.join and os.path.join
def setUp(self): """setup""" self.cwd = os.getcwd() self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH, GITHUB_LOGIN, GITHUB_PASSWORD, GITHUB_TOKEN)
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)
def setUp(self): """setup""" super(GithubTest, self).setUp() self.ghfs = Githubfs(GITHUB_USER, GITHUB_REPO, GITHUB_BRANCH, GITHUB_LOGIN, GITHUB_PASSWORD, GITHUB_TOKEN)