Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated testing #93

Closed
wants to merge 7 commits into from
Closed

Add automated testing #93

wants to merge 7 commits into from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jul 11, 2017

The goal of this change is to have Travis-CI automatically run flake8 tests on every pull request. This will help contributors know if their submissions are going to break the build. To turn on this free service, you would need to do steps 1 and 2 of https://docs.travis-ci.com/user/getting-started/

The goal of this change is to have Travis-CI automatically run [flake8](http://flake8.readthedocs.io) tests on every pull request. This will help contributors know if their submissions are going to *break the build*. To turn on this **free** service, you would need to do steps 1 and 2 of https://docs.travis-ci.com/user/getting-started/
@polyzen
Copy link

polyzen commented Jul 11, 2017

Is Trusty needed for this? If not, I would omit the first two lines. sudo: false is the default, and Trusty will start to be the default next week, anyhow.

@polyzen
Copy link

polyzen commented Jul 11, 2017

You could also omit the patch versions.

Copy link
Owner

@donnemartin donnemartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cclauss @polyzen thanks for the PR and comments! I think I'm a little confused...with many of the code samples not being fully runnable (ie some are pseudocode or stubbed out), how does that affect the need and effectiveness of automated testing?

@cclauss
Copy link
Contributor Author

cclauss commented Jul 18, 2017

People are going to assume that files with filenames that end in .py contain valid, executable Python code. Flakes8 verifies this. If the filename ends in .py then flake8 is going to scan the file looking for and flagging any text which is not valid Python code.

For your files to get a passing grade you have at least three options:

  1. End the filenames of the files containing pseudocode with .txt, .md, etc. but not .py
  2. Comment out the pseudocode with a leading #
  3. Put the pseudocode inside triple quotes ''' ''' or """ """

@cclauss
Copy link
Contributor Author

cclauss commented Aug 15, 2017

#98 demonstrates how we can modify the code to be lintable but still clearly indicate where the user needs to add code.

polyzen referenced this pull request in akrennmair/newsbeuter Aug 31, 2017
@cclauss
Copy link
Contributor Author

cclauss commented Sep 6, 2017

This is what the output looks like before #98

cclauss pushed a commit to cclauss/system-design-primer that referenced this pull request Mar 7, 2018
@cclauss
Copy link
Contributor Author

cclauss commented Mar 14, 2018

I understand that we are treating these files largely as pseudocode but I still believe that this PR is required. It is a distraction for readers who know Python if the psudocode that they are reading contains syntax errors and variable names that do not match up.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 9, 2018

The output is looking better but we still have to correct one syntax error and 10 undefined names.

#149 Resolves the syntax error and 4 of the undefined names.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 26, 2018

#149 has been merged so the syntax error is resolved and we are down to seven undefined names.

flake8 testing of https://github.com/donnemartin/system-design-primer on Python 3.6.3

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./solutions/object_oriented_design/online_chat/online_chat.py:98:21: F821 undefined name 'Enum'
class RequestStatus(Enum):
                    ^
./solutions/object_oriented_design/parking_lot/parking_lot.py:67:22: F821 undefined name 'levels'
        for level in levels:
                     ^
./solutions/system_design/mint/mint_mapreduce.py:36:28: F821 undefined name 'category'
            yield (period, category), amount
                           ^
./solutions/system_design/mint/mint_snippets.py:3:25: F821 undefined name 'Enum'
class DefaultCategories(Enum):
                        ^
./solutions/system_design/social_graph/social_graph_snippets.py:12:30: F821 undefined name 'State'
        source.visit_state = State.visited
                             ^
./solutions/system_design/social_graph/social_graph_snippets.py:19:49: F821 undefined name 'State'
                if adjacent_node.visit_state == State.unvisited:
                                                ^
./solutions/system_design/social_graph/social_graph_snippets.py:21:49: F821 undefined name 'State'
                    adjacent_node.visit_state = State.visited
                                                ^
7     F821 undefined name 'Enum'
7

cclauss pushed a commit to cclauss/system-design-primer that referenced this pull request Apr 26, 2018
__levels__ is an _undefined name in this context (see donnemartin#93) so replace it with __self.levels__ which is defined a few lines above.
cclauss pushed a commit to cclauss/system-design-primer that referenced this pull request Apr 26, 2018
In the current code, __seller__ is an unused variable and __category__ is an undefined name (see donnemartin#93).

Given that the class is __SpendingByCategory__, this PR advocates changing seller —> category.
@cclauss
Copy link
Contributor Author

cclauss commented May 7, 2018

After more merges, we are down to just two items one item before these tests will pass.

flake8 testing of https://github.com/donnemartin/system-design-primer on Python 3.6.3

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./solutions/system_design/social_graph/social_graph_snippets.py:12:30: F821 undefined name 'State'
        source.visit_state = State.visited
                             ^
./solutions/system_design/social_graph/social_graph_snippets.py:19:49: F821 undefined name 'State'
                if adjacent_node.visit_state == State.unvisited:
                                                ^
./solutions/system_design/social_graph/social_graph_snippets.py:21:49: F821 undefined name 'State'
                    adjacent_node.visit_state = State.visited
                                                ^
3     F821 undefined name 'State'
3

cclauss pushed a commit to cclauss/system-design-primer that referenced this pull request May 30, 2018
Allows donnemartin#93 to be merged and the Travis CI tests to pass even before a solution to donnemartin#148 is proposed.
donnemartin#162 Temporarily suppress flake8 testing of social_graph_snippets.py
cclauss pushed a commit to cclauss/system-design-primer that referenced this pull request Jul 13, 2018
@cclauss
Copy link
Contributor Author

cclauss commented Jul 15, 2018

Given recent pull requests, these flake8 tests pass.

@cclauss
Copy link
Contributor Author

cclauss commented Jul 19, 2018

@polyzen Can I please get your review on these proposed changes?

@cclauss
Copy link
Contributor Author

cclauss commented Aug 21, 2018

Bump on this one?

@cclauss cclauss closed this Oct 28, 2018
@cclauss cclauss deleted the patch-1 branch October 28, 2018 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants