101 test tableauauth model.py#134
Conversation
…mplfied test to check for just the TypeError and ignore the exception text
|
🚀 lgtm. Sadly the analytics script commits is cruft that will stick around for a little while. |
|
On a related note, could you explain how I can create the test coverage stats in order to update the stats in #101? |
|
@talvalin if you coverage run --source=tableauserverclient setup.py test
coverage reportThis should give you an output that looks like this: |
|
|
||
|
|
||
| class TableauAuthModelTests(unittest.TestCase): | ||
| def test_username_password_required(self): |
There was a problem hiding this comment.
Just assertRaises the cm object doesn't get used so no need.
There was a problem hiding this comment.
Uh, if I remove the cm object, the TypeError gets thrown without being handled and so winds up as an error in the test.
self.assertRaises(TypeError, TSC.TableauAuth())
What am I doing wrong here?
There was a problem hiding this comment.
Don't remove it, just don't name it.
with self.assertRaises(TypeError):
TSC.TableauAuth()The as context_manager wasn't necessary because you didn't use the object.
The context manager itself is the way to go
There was a problem hiding this comment.
Ah. That makes sense. Cool.
test/test_tableauauth_model.py
Outdated
|
|
||
| def test_site_arg_raises_warning(self): | ||
| with warnings.catch_warnings(record=True) as w: | ||
| # Cause all warnings to always be triggered. |
There was a problem hiding this comment.
Comment is unnecessary given the name of the option in the code :)
| # Cause all warnings to always be triggered. | ||
| warnings.simplefilter("always") | ||
|
|
||
| tableau_auth = TSC.TableauAuth('user', |
There was a problem hiding this comment.
That's not the right kind of site id.
This is the site name in the URL just like tabcmd.
test/test_tableauauth_model.py
Outdated
| site='dad65087-b08b-4603-af4e-2887b8aafc67') | ||
|
|
||
| assert len(w) == 1 | ||
| assert issubclass(w[-1].category, DeprecationWarning) |
There was a problem hiding this comment.
Use asserttrue or assert equals? The bare asserts aren't the right style for unittest, that's more of a pytest thing
There was a problem hiding this comment.
Will fix, but apparently testing the warning type is proving fun via the unittest asserts.
|
So I updated following your comments, but I'm finding it hard to test the warnings inside the getter and setter. I tried explicitly calling them in a test, but the coverage report maintains that the lines inside each function are not being called. :( |
|
Coverage report for models\tableau_auth.py says: Better than 50%, but still sucking slightly. |
|
@talvalin I say go ahead and remove the deprecation tests for now -- they'll go away to the tests aren't long term useful. Focus on covering all the remaining lines (if they aren't already by your PR, I haven't had a chance to test locally) |
|
@RussTheAerialist @t8y8 - So any thoughts on how I can test the getters and setters, or should I just ignore those? |
|
Don't worry about it for now, no reason to hold this improvement up! |
test/test_tableauauth_model.py
Outdated
| def setUp(self): | ||
| self.auth = TSC.TableauAuth('user', | ||
| 'password', | ||
| site_id='dad65087-b08b-4603-af4e-2887b8aafc67', |
There was a problem hiding this comment.
Wrong site id type still.
This is the thing in the url after /t/ or /site/ NOT a luid.
Just make it the string site1
|
I realise that you said to take out the warning check, but without that test the coverage stays at 50% rather than 67% so I left it in. |
|
🚀 some test coverage is better than none. Let's get this in (it's hackathon!) clear the PRs! |
Improve coverage in the auth model tests. Original patch by @talvalin
I thought I branched from development this time, but I'm still getting the analytics files in my pull request. How do I fix this? :(