Added unit tests for rbt alias command

Review Request #10989 — Created April 4, 2020 and updated

kpatenio
RBTools
release-2.0.x
rbtools
Added unit tests for rbt alias command

Test cases run on python 2.7.17 and 3.7.6.

- Test case validating output for '--list' option with defined alias
- Test case validating output for '--list' option  with undefined alias
- Test case validating '--list' option in debug mode
- Test case validating output for '--dry-run' option with defined alias
- Test case validating output for '--dry-run' option with undefined alias
- Test case validating  '--dry-run' option with missing arg
- Test case validating '--dry-run' option in debug mode
Summary Author
Added unit tests for rbt alias command
kpatenio
Description From Last Updated

For mentors: flake8 does not seem to like the fact that I have repeated dictionary keys in a couple test ...

kpateniokpatenio

Since this can get a bit weird-looking, the pattern we prefer is: config = { 'ALIASES': { ... } } ...

chipx86chipx86

F601 dictionary key u'alias1' repeated with different values

reviewbotreviewbot

F601 dictionary key u'alias1' repeated with different values

reviewbotreviewbot

F601 dictionary key u'alias1' repeated with different values

reviewbotreviewbot

F601 dictionary key u'alias1' repeated with different values

reviewbotreviewbot

Mentioned this in another review request, but you'll want to use += for consistency and performance (this isn't performance-critical code, ...

chipx86chipx86
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

kpatenio
  1. 
      
  2. For mentors: flake8 does not seem to like the fact that I have repeated dictionary keys in a couple test cases that I made.

    Would you recommend I ignore these? Or should I omit this type of test case from my unit tests?

    1. Repeated dictionary keys will get filtered out, so they are a problem. Only one key will win, and which one will depend on the version of Python you're working with. You're probably not getting the testing you're expecting with that.

    2. Ah that's interesting. Considering that the key chosen depends on the Python version, I feel inclined to remove these tests for now.

  3. 
      
chipx86
  1. 
      
  2. rbtools/commands/tests/test_alias.py (Diff revision 1)
     
     
     
     
     

    Since this can get a bit weird-looking, the pattern we prefer is:

    config = {
        'ALIASES': {
            ...
        }
    }
    
    with self.reviewboardrc(config):
        ...
    

    Keeps it a lot more manageable.

  3. rbtools/commands/tests/test_alias.py (Diff revision 1)
     
     

    Mentioned this in another review request, but you'll want to use += for consistency and performance (this isn't performance-critical code, but still worth doing).

  4. 
      
kpatenio
kpatenio
Review request changed

Change Summary:

Updated description

Testing Done:

   

Test cases run on python 2.7.17 and 3.7.6.

   
   
- Test case validating output for '--list' option with defined alias
   
- Test case validating output for '--list' option  with undefined alias
-  
- Test case validating output for '--list' option with duplicated alias
   
- Test case validating '--list' option in debug mode
   
- Test case validating output for '--dry-run' option with defined alias
   
- Test case validating output for '--dry-run' option with undefined alias
   
- Test case validating  '--dry-run' option with missing arg
-  
- Test case validating output for  '--dry-run' option with duplicated alias
   
- Test case validating '--dry-run' option in debug mode
Loading...