This pull request primarily addresses upgrading/refactoring the existing suite of unit tests - coverage has now increased from 69% to 87%.
I have also performed minor refactoring for the source code:
Reddit object schema has been defined in a separate file located in urs/praw_scrapers/utils named Objectify.py to ensure DRY code.
Removed some unused method parameters in various files.
After a bit of confusion, I have also migrated the repository from travis-ci.org to travis-ci.com since they are migrating everything to the .com domain. From my understanding, Travis-CI formerly used the .org domain for open-source projects and the .com domain for enterprise use, but why they did not just host their services on one domain in the first place is beyond me.
Motivation/Context
Travis CI allows setting encrypted environmental variables. Previous iterations did not take advantage of this feature because PRAW API credentials needed to be hard-coded into the deprecated Credentials.py file. After merging pull #26, it is possible for me to write real unit tests using my personal development API credentials since they are now stored in the .env file.
New Dependencies
None
Issue Fix or Enhancement Request
N/A
Type of Change
[x] Code Refactor
Breaking Change
N/A
List All Changes That Have Been Made
Added
Source code
Added a new file within urs/praw_scrapers/utils named Objectify.py.
This file includes schema for Reddit objects that are used by Comments.py, Redditor.py, and Subreddit.py.
Tests
Added conftest.py, which contains a cleanup script that is executed after pytest is done with all tests.
Added real unit tests for source code that pulls data via PRAW:
Comments.py
Redditor.py
Subreddit.py
Added additional tests for the following files:
Cli.py
Changed
Source code
Moved Reddit object schemas that were previously defined in their respective PRAW scraper files to Objectify.py:
Within Comments.py:
CreateComment.create()
Within Redditor.py:
Objectify().make_comment()
Objectify().make_multireddit()
Objectify().make_submission()
Objectify().make_subreddit()
Within Subreddit.py:
FormatSubmissions._make_submission()
Removed unused method parameters in various scripts:
Basic.py
Cli.py
Comments.py
PrepData.py
Redditor.py
Subreddit.py
Tools.py
Validation.py
Tests
Grouped tests based on their corresponding module.
Added new unit tests for the following pytest files:
test_Comments.py
test_Objectify.py
test_PrepData.py
test_Redditor.py
test_Subreddit.py
test_Validation.py
Community documents
Updated STYLE_GUIDE.md to reflect new unit test style.
Added a new YAML block to PULL_REQUEST_TEMPLATE.md to document any new changes made to .travis.yml.
Deprecated
Tests
Replaced previously useless unit tests with upgraded tests that pull data via PRAW.
How Has This Been Tested?
Ran pytest on local machine - all tests have passed.
Overview
Summary
This pull request primarily addresses upgrading/refactoring the existing suite of unit tests - coverage has now increased from 69% to 87%.
I have also performed minor refactoring for the source code:
urs/praw_scrapers/utils
namedObjectify.py
to ensure DRY code.After a bit of confusion, I have also migrated the repository from travis-ci.org to travis-ci.com since they are migrating everything to the .com domain. From my understanding, Travis-CI formerly used the .org domain for open-source projects and the .com domain for enterprise use, but why they did not just host their services on one domain in the first place is beyond me.
Motivation/Context
Travis CI allows setting encrypted environmental variables. Previous iterations did not take advantage of this feature because PRAW API credentials needed to be hard-coded into the deprecated
Credentials.py
file. After merging pull #26, it is possible for me to write real unit tests using my personal development API credentials since they are now stored in the.env
file.New Dependencies
Issue Fix or Enhancement Request
N/A
Type of Change
Breaking Change
N/A
List All Changes That Have Been Made
Added
urs/praw_scrapers/utils
namedObjectify.py
.Comments.py
,Redditor.py
, andSubreddit.py
.conftest.py
, which contains a cleanup script that is executed afterpytest
is done with all tests.Comments.py
Redditor.py
Subreddit.py
Cli.py
Changed
Objectify.py
:Comments.py
:CreateComment.create()
Redditor.py
:Objectify().make_comment()
Objectify().make_multireddit()
Objectify().make_submission()
Objectify().make_subreddit()
Subreddit.py
:FormatSubmissions._make_submission()
Basic.py
Cli.py
Comments.py
PrepData.py
Redditor.py
Subreddit.py
Tools.py
Validation.py
pytest
files:test_Comments.py
test_Objectify.py
test_PrepData.py
test_Redditor.py
test_Subreddit.py
test_Validation.py
STYLE_GUIDE.md
to reflect new unit test style.PULL_REQUEST_TEMPLATE.md
to document any new changes made to.travis.yml
.Deprecated
How Has This Been Tested?
pytest
on local machine - all tests have passed.Test Configuration
Travis CI configuration:
Dependencies
N/A
Checklist