forked from rockstor/rockstor-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(t) Refresh/remove all test fixtures and update tests accordingly roc…
…kstor#2384 As a result of major Django changes enacted in 'Update Django within current Python 2 constrains rockstor#2254' rockstor#2365, and following on from the fixture re-enablement spin-off of the former: '(t) Test fixtures non functional rockstor#2382' rockstor#2383 we have a test wide requirement to update or remove our now mostly outdated and newly re-enabled fixtures. Our prior work-around for the previously dysfunctional fixtures was extensive in-test db object mocking. This has become unworkable and incompatible with our newer Django. ## Includes - remove now outdated trailing '/' in task post calls rockstor#2384 Thanks to FroggyFlox for pointers: in GitHub issue rockstor#2370 we recently removed the trailing slash for post calls on tasks. Adjust task unit tests accordingly. - minor existing fixture update to be compatible with newer auth arrangement via independent fixture. - del redundant/legacy fixture/inheritance - multiple tests. - Addition on now independent test_api.json auth feature. - Black formatting. - del redundant/legacy fixture/inheritance - test_pool_balance. - Remove redundant fixtures and their references. - Addition on now independent test_api.json auth feature. - Add test run command. - Addition instructions on fixture content and creation. - Removing numerous now incompatible db object mocking as we now have working fixtures. - Improve test_api.py re setUpClass/tearDownClass supers rockstor#2382 Thanks to FroggyFlox on Github for follow-up work in this area. - Restore previously remarked out, existing snapshot delete test. - move smart run_test mock down to system - test_disk_smart.py. Thanks to FroggyFlox on GitHub. Our initial mock was failing, covered up by as yet only local testing. Moving the mock to the source of its definition resolves a failed mock. - Reviving a number of previously unworkable tests. - Improving test group names for clarity. - Test re-ordering for clarity. - Breaking out more tests into their own sets rather than repeat for all raid levels. - Improved/simplified mocking. - add todo, debug logging, and comments to pool.py concerning issue rockstor#2384 - Simplify mocking of pool_usage in line with recent tested code changes.
- Loading branch information
Showing
42 changed files
with
3,575 additions
and
56,347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,36 +124,5 @@ | |
"display_name": "NUT-UPS", | ||
"name": "nut" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "auth.user", | ||
"fields": { | ||
"username": "admin", | ||
"first_name": "", | ||
"last_name": "", | ||
"is_active": true, | ||
"is_superuser": false, | ||
"is_staff": false, | ||
"last_login": "2014-11-05T14:19:15.421Z", | ||
"groups": [], | ||
"user_permissions": [], | ||
"password": "pbkdf2_sha256$12000$bIlTp3bZu4if$HhIMeQVPN/0NJz0NtrVj7ib8h+xHZkUT/md5DaPlq6A=", | ||
"email": "", | ||
"date_joined": "2014-11-05T14:19:13.535Z" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "oauth2_provider.application", | ||
"fields": { | ||
"redirect_uris": "", | ||
"name": "cliapp", | ||
"client_type": "confidential", | ||
"user": 1, | ||
"client_id": "y5s_6Ge1yP.xUacU_U9_;t.bdAosyX43a2Of.kdH", | ||
"client_secret": "wIsVYk0=14O?JylV.Y7p2lcOnIeWmC_lZEuKy@[email protected]=ttbOzG-e;U:qlkpx-:Vr3-l-Gh1ab2nkukMRkst01EsvBL-5Ld_jw6I-K", | ||
"authorization_grant_type": "client-credentials" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,11 +22,13 @@ | |
|
||
class SNMPTests(APITestCase): | ||
multi_db = True | ||
fixtures = ['services.json'] | ||
BASE_URL = '/api/sm/services/snmpd' | ||
# TODO Requires command to reproduce minimal fixture: | ||
# "services.json" fixture requires only the smart_manager.service model. | ||
fixtures = ["test_api.json", "services.json"] | ||
BASE_URL = "/api/sm/services/snmpd" | ||
|
||
def session_login(self): | ||
self.client.login(username='admin', password='admin') | ||
self.client.login(username="admin", password="admin") | ||
|
||
def test_snmp_0(self): | ||
""" | ||
|
@@ -39,105 +41,128 @@ def test_snmp_0_1(self): | |
""" | ||
config happy path | ||
""" | ||
config = {'syslocation': 'Rockstor Labs', | ||
'syscontact': '[email protected]', | ||
'rocommunity': 'public', | ||
'aux': (), } | ||
data = {'config': config, } | ||
config = { | ||
"syslocation": "Rockstor Labs", | ||
"syscontact": "[email protected]", | ||
"rocommunity": "public", | ||
"aux": (), | ||
} | ||
data = {"config": config} | ||
self.session_login() | ||
response = self.client.post('%s/config' % self.BASE_URL, data=data) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK, | ||
msg=response.content) | ||
response = self.client.post("%s/config" % self.BASE_URL, data=data) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response.content) | ||
|
||
def test_snmp_1(self): | ||
""" | ||
config without input | ||
""" | ||
self.session_login() | ||
response = self.client.post('%s/config' % self.BASE_URL) | ||
self.assertEqual(response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content) | ||
response = self.client.post("%s/config" % self.BASE_URL) | ||
self.assertEqual( | ||
response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content, | ||
) | ||
|
||
def test_snmp_2(self): | ||
""" | ||
config without syslocation | ||
""" | ||
config = {'syscontact': '[email protected]', | ||
'rocommunity': 'public', | ||
'aux': (), } | ||
data = {'config': config, } | ||
config = { | ||
"syscontact": "[email protected]", | ||
"rocommunity": "public", | ||
"aux": (), | ||
} | ||
data = {"config": config} | ||
self.session_login() | ||
response = self.client.post('%s/config' % self.BASE_URL, data=data) | ||
self.assertEqual(response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content) | ||
response = self.client.post("%s/config" % self.BASE_URL, data=data) | ||
self.assertEqual( | ||
response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content, | ||
) | ||
|
||
def test_snmp_3(self): | ||
""" | ||
config without syscontact | ||
""" | ||
config = {'syslocation': 'Rockstor Labs', | ||
'rocommunity': 'public', | ||
'aux': (), } | ||
config = {"syslocation": "Rockstor Labs", "rocommunity": "public", "aux": ()} | ||
self.session_login() | ||
response = self.client.post('%s/config' % self.BASE_URL, | ||
data={'config': config, }) | ||
self.assertEqual(response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content) | ||
response = self.client.post( | ||
"%s/config" % self.BASE_URL, data={"config": config} | ||
) | ||
self.assertEqual( | ||
response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content, | ||
) | ||
|
||
def test_snmp_4(self): | ||
""" | ||
config without rocommunity | ||
""" | ||
config = {'syslocation': 'Rockstor Labs', | ||
'syscontact': '[email protected]', | ||
'aux': (), } | ||
config = { | ||
"syslocation": "Rockstor Labs", | ||
"syscontact": "[email protected]", | ||
"aux": (), | ||
} | ||
self.session_login() | ||
response = self.client.post('%s/config' % self.BASE_URL, | ||
data={'config': config, }) | ||
self.assertEqual(response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content) | ||
response = self.client.post( | ||
"%s/config" % self.BASE_URL, data={"config": config} | ||
) | ||
self.assertEqual( | ||
response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content, | ||
) | ||
|
||
def test_snmp_5(self): | ||
""" | ||
config without aux | ||
""" | ||
config = {'syslocation': 'Rockstor Labs', | ||
'syscontact': '[email protected]', | ||
'rocommunity': 'public', } | ||
config = { | ||
"syslocation": "Rockstor Labs", | ||
"syscontact": "[email protected]", | ||
"rocommunity": "public", | ||
} | ||
self.session_login() | ||
response = self.client.post('%s/config' % self.BASE_URL, | ||
data={'config': config, }) | ||
self.assertEqual(response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content) | ||
response = self.client.post( | ||
"%s/config" % self.BASE_URL, data={"config": config} | ||
) | ||
self.assertEqual( | ||
response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content, | ||
) | ||
|
||
def test_snmp_6(self): | ||
""" | ||
config with wrong aux type | ||
""" | ||
config = {'syslocation': 'Rockstor Labs', | ||
'syscontact': '[email protected]', | ||
'rocommunity': 'public', | ||
'aux': 'foo', } | ||
config = { | ||
"syslocation": "Rockstor Labs", | ||
"syscontact": "[email protected]", | ||
"rocommunity": "public", | ||
"aux": "foo", | ||
} | ||
self.session_login() | ||
response = self.client.post('%s/config' % self.BASE_URL, | ||
data={'config': config, }) | ||
self.assertEqual(response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content) | ||
response = self.client.post( | ||
"%s/config" % self.BASE_URL, data={"config": config} | ||
) | ||
self.assertEqual( | ||
response.status_code, | ||
status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
msg=response.content, | ||
) | ||
|
||
def test_snmp_7(self): | ||
""" | ||
start/stop tests | ||
""" | ||
self.session_login() | ||
response = self.client.post('%s/start' % self.BASE_URL) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK, | ||
msg=response.content) | ||
response2 = self.client.post('%s/stop' % self.BASE_URL) | ||
self.assertEqual(response2.status_code, status.HTTP_200_OK, | ||
msg=response.content) | ||
response = self.client.post("%s/start" % self.BASE_URL) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response.content) | ||
response2 = self.client.post("%s/stop" % self.BASE_URL) | ||
self.assertEqual( | ||
response2.status_code, status.HTTP_200_OK, msg=response.content | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.