Add new unit tests for RBTools's Git support

Review Request #8099 - Created April 4, 2016 and submitted

Shaurya Sengar
RBTools
master
rbtools

Add new unit tests for RBTools's Git support (this review request covers most of the tests in the project description at https://student-sonar.herokuapp.com/projects)

Wrote the following test cases for the following methods of the the GitClient class -

Method name - push_upstream() -
1) Tested push_upstream() with an invalid target branch. The 'git_pull' must raise a PushError exception.
2) Tested push_upstream() with the push_url set to be an invalid one. Neither the 'pull' or the 'push' must raise an exception because it gets it's origin_url from the Git config which still has a valid fetch_url

Method name - merge()
1) Tested merge() with invalid target and destination branches. Both of these must raise a MergeError exception
2) Tested merge() with squash set to True and False. Used a KGB spy to check if execute was called with the right arguments.

Method name - create_commit()
1) Tested create_commit() with run_editor set to True and False. Used a KGB spy to check if edit_text was called or not.
2) Tested create_commit() with all_files set to True and False. Used a KGB spy to check if execute was called with the right arguments.

Method name - delete_branch()
1) Tested delete_branch() with merged_only set to True and False. Used a KGB spy to check if execute was called with the right arguments.

  • 0
  • 0
  • 63
  • 21
  • 84
Description From Last Updated
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/tests.py
    
    
  2. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 59
     W291 trailing whitespace
    
  3. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 45
     W291 trailing whitespace
    
  4. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 60
     W291 trailing whitespace
    
  5. rbtools/clients/tests.py (Diff revision 1)
     
     
     local variable 'e' is assigned to but never used
    
  6. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 45
     W291 trailing whitespace
    
  7. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 1
     W293 blank line contains whitespace
    
  8. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 5
     E303 too many blank lines (2)
    
  9. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 63
     W291 trailing whitespace
    
  10. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 63
     W291 trailing whitespace
    
  11. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 45
     W291 trailing whitespace
    
  12. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 58
     W291 trailing whitespace
    
  13. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 63
     W291 trailing whitespace
    
  14. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 77
     W291 trailing whitespace
    
  15. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 45
     W291 trailing whitespace
    
  16. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 64
     W291 trailing whitespace
    
  17. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 76
     W291 trailing whitespace
    
  18. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 32
     E711 comparison to None should be 'if cond is not None:'
    
  19. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 65
     W291 trailing whitespace
    
  20. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 75
     W291 trailing whitespace
    
  21. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 68
     W291 trailing whitespace
    
  22. rbtools/clients/tests.py (Diff revision 1)
     
     
    Col: 32
     E711 comparison to None should be 'if cond is not None:'
    
  23. 
      
Shaurya Sengar
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/tests.py
    
    
  2. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 45
     W291 trailing whitespace
    
  3. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 60
     E231 missing whitespace after ':'
    
  4. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 68
     W291 trailing whitespace
    
  5. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 57
     E231 missing whitespace after ':'
    
  6. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 60
     E231 missing whitespace after ':'
    
  7. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 68
     W291 trailing whitespace
    
  8. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 57
     E231 missing whitespace after ':'
    
  9. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 60
     E231 missing whitespace after ':'
    
  10. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 68
     W291 trailing whitespace
    
  11. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 57
     E231 missing whitespace after ':'
    
  12. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  13. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 60
     E231 missing whitespace after ':'
    
  14. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 68
     W291 trailing whitespace
    
  15. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 57
     E231 missing whitespace after ':'
    
  16. rbtools/clients/tests.py (Diff revision 2)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  17. 
      
Shaurya Sengar
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/tests.py
    
    
  2. rbtools/clients/tests.py (Diff revision 3)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  3. rbtools/clients/tests.py (Diff revision 3)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  4. 
      
Shaurya Sengar
Mike Conley
  1. Hey - I think these are on the right track. Great job!

    Don't forget to test the success cases too.

  2. rbtools/clients/tests.py (Diff revision 3)
     
     
     

    You could put this after the push_upstream call on line 538 - that way, you wouldn't need the early return in 541.

  3. rbtools/clients/tests.py (Diff revision 3)
     
     

    Don't forget to test the success case too.

  4. rbtools/clients/tests.py (Diff revision 3)
     
     

    assertTrue(False) after line 551? Same goes for other tests like this.

  5. rbtools/clients/tests.py (Diff revision 3)
     
     
     

    I'm guessing this is just placeholder?

    1. Umm no it's not really a placeholder. For my create_commit() tests, I needed to call a fake method instead of edit_text() when it was called. So this is that fake method which is called instead of edit_text() (which is needed because edit_text opens up a Vim window and waits for user input). Hence, you'll see the corresponding line agency.spy_on(edit_text, call_fake=self.return_new_message) in my code. Is there a better way of doing this without having to define a new method (maybe using Lambda functions)?

  6. 
      
Shaurya Sengar
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/tests.py
    
    
  2. rbtools/clients/tests.py (Diff revision 4)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  3. rbtools/clients/tests.py (Diff revision 4)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  4. rbtools/clients/tests.py (Diff revision 4)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  5. rbtools/clients/tests.py (Diff revision 4)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  6. rbtools/clients/tests.py (Diff revision 4)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  7. rbtools/clients/tests.py (Diff revision 4)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  8. rbtools/clients/tests.py (Diff revision 4)
     
     
    Col: 76
     W291 trailing whitespace
    
  9. 
      
Shaurya Sengar
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/tests.py
    
    
  2. rbtools/clients/tests.py (Diff revision 5)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  3. rbtools/clients/tests.py (Diff revision 5)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  4. rbtools/clients/tests.py (Diff revision 5)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  5. rbtools/clients/tests.py (Diff revision 5)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  6. rbtools/clients/tests.py (Diff revision 5)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  7. rbtools/clients/tests.py (Diff revision 5)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  8. 
      
David Trowbridge
  1. 
      
  2. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  3. rbtools/clients/tests.py (Diff revision 5)
     
     
     
     
     
     
     
     
     

    This could all be done at once using six.assertRaisesRegexp.

  4. rbtools/clients/tests.py (Diff revision 5)
     
     
     
     
     
     
     

    Instead of catching the exception and doing assertTrue(False), just get rid of the try/except. An uncaught exception will cause the test case to fail.

  5. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  6. rbtools/clients/tests.py (Diff revision 5)
     
     
     
     
     
     
     
     
     
     

    This can use six.assertRaisesRegexp

  7. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  8. rbtools/clients/tests.py (Diff revision 5)
     
     
     

    Can we reformat/change this to:

    author = type(
        b'Author',
        (object,),
        {
            'fullname': 'name',
            'email': 'email',
        })
    
  9. rbtools/clients/tests.py (Diff revision 5)
     
     
     
     

    six.assertRaisesMessage

  10. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  11. rbtools/clients/tests.py (Diff revision 5)
     
     

    If you add SpyAgency as a parent class, you can use self.spy_on(execute). This has several advantages: you don't have to create a new SpyAgency for each test, and it will automatically unspy after each test case (which is both less code and more robust if there are unexpected exceptions).

  12. rbtools/clients/tests.py (Diff revision 5)
     
     
     

    Same formatting here as I mentioned above.

  13. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  14. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  15. rbtools/clients/tests.py (Diff revision 5)
     
     
     

    Same formatting here as above.

  16. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  17. rbtools/clients/tests.py (Diff revision 5)
     
     
     

    And here.

  18. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  19. rbtools/clients/tests.py (Diff revision 5)
     
     
     

    And here. Since we're using this in lots of places, perhaps we should define this once?

  20. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  21. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  22. rbtools/clients/tests.py (Diff revision 5)
     
     

    """ on the next line.

  23. 
      
Shaurya Sengar
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/tests.py
    
    
  2. rbtools/clients/tests.py (Diff revision 6)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  3. rbtools/clients/tests.py (Diff revision 6)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  4. rbtools/clients/tests.py (Diff revision 6)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  5. rbtools/clients/tests.py (Diff revision 6)
     
     
    Col: 50
     E127 continuation line over-indented for visual indent
    
  6. rbtools/clients/tests.py (Diff revision 6)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  7. rbtools/clients/tests.py (Diff revision 6)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  8. 
      
Shaurya Sengar
Review Bot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/tests.py
    
    
  2. rbtools/clients/tests.py (Diff revision 7)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  3. rbtools/clients/tests.py (Diff revision 7)
     
     
    Col: 33
     E128 continuation line under-indented for visual indent
    
  4. 
      
David Trowbridge
  1. Going to make some small changes and push this.

  2. 
      
Shaurya Sengar
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.7.x (d8a346f)
Loading...