From 2af460eefdaa9d365e5e2b4fab11583fd1e6def9 Mon Sep 17 00:00:00 2001 From: Daniel Lebedinsky Date: Sun, 19 Nov 2023 19:56:03 -0500 Subject: [PATCH 1/2] Fixed test_bibtex unit test, updated CONTRIBUTING.md --- .github/CONTRIBUTING.md | 13 +++++++------ test_module.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9f80eb12..abace071 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -16,12 +16,13 @@ Additionally, if you are interesting in contributing to the codebase, submit a p ## How to contribute -1. Create a fork of `scholarly-python-package/scholarly` repository. -2. If you add a new feature, try to include tests in already existing test cases, or create a new test case if that is not possible. -3. Make sure the unit tests pass before raising a PR. For all the unit tests to pass, you typically need to setup a premium proxy service such as `ScraperAPI` or `Luminati` (`Bright Data`). If you do not have an account, you may try to use `FreeProxy`. Without a proxy, 6 out of 17 test cases will be skipped. -4. Check that the documentatation is consistent with the code. Check that the documentation builds successfully. -5. Submit a PR, with `develop` as your base branch. -6. After an initial code review by the maintainers, the unit tests will be run with the `ScraperAPI` key stored in the Github repository. Passing all tests cases is necessary before merging your PR. +1. Create a fork of `scholarly-python-package/scholarly` repository. Make sure that "Copy the main branch only" is **not** checked off. +2. After cloning your fork and checking out into the develop branch, run `python setup.py --help-commands` for more info on how to install dependencies and build. You may need to run it with `sudo`. +3. If you add a new feature, try to include tests in already existing test cases, or create a new test case if that is not possible. For a comprehensive output, run `python -m unittest -v test_module.py` +4. Make sure the unit tests pass before raising a PR. For all the unit tests to pass, you typically need to setup a premium proxy service such as `ScraperAPI` or `Luminati` (`Bright Data`). By default, `python setup.py install` will get `FreeProxy`. Without a proxy, 6 out of 17 test cases will be skipped. +5. Check that the documentatation is consistent with the code. Check that the documentation builds successfully. +6. Submit a PR, with `develop` as your base branch. +7. After an initial code review by the maintainers, the unit tests will be run with the `ScraperAPI` key stored in the Github repository. Passing all tests cases is necessary before merging your PR. ## Build Docs diff --git a/test_module.py b/test_module.py index b2a3ac5b..a0b5ac7f 100644 --- a/test_module.py +++ b/test_module.py @@ -690,7 +690,7 @@ def test_bibtex(self): Test that we get the BiBTeX entry correctly """ - with open("testdata/bibtex.txt", "r") as f: + with open("testdata/test_bibtex_result.txt", "r") as f: expected_result = "".join(f.readlines()) pub = scholarly.search_single_pub("A distribution-based clustering algorithm for mining in large " From ba3b8a4fb56d72fcf7ff89208021d679cae12b51 Mon Sep 17 00:00:00 2001 From: Daniel Lebedinsky Date: Wed, 29 Nov 2023 00:11:55 -0500 Subject: [PATCH 2/2] Added test for FreeProxy --- test_module.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test_module.py b/test_module.py index a0b5ac7f..43c8b5ae 100644 --- a/test_module.py +++ b/test_module.py @@ -78,6 +78,20 @@ def test_tor_launch_own_process(self): authors = [a for a in scholarly.search_author(query)] self.assertGreaterEqual(len(authors), 1) +class TestFreeProxy(unittest.TestCase): + luminati = os.getenv("USERNAME") and os.getenv("PASSWORD") and os.getenv("PORT") + scraperAPI = os.getenv('SCRAPER_API_KEY') + skipIf = (luminati is not None) or (scraperAPI is not None) + + @unittest.skipIf(skipIf, reason="Other proxy is being used") + def test_freeproxy(self): + """ + Test that we can set up FreeProxy successfully + """ + proxy_generator = ProxyGenerator() + success = proxy_generator.FreeProxies() + self.assertTrue(success) + self.assertEqual(proxy_generator.proxy_mode, "FREE_PROXIES") class TestScholarly(unittest.TestCase):