forked from emre/storm
-
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.
Updated behaviours of add/edit commands, added a search command.
* New behaviour of add/edit: NEW: storm add name host@server:port OLD: storm add name host server --port NEW: storm edit name host@server:port OLD: storm edit name host server --port * Added a search command for searching host entries $ storm search vps Listing results for vps: vps -> [email protected]:22
- Loading branch information
Showing
5 changed files
with
76 additions
and
2 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
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 |
---|---|---|
|
@@ -2,4 +2,8 @@ | |
|
||
|
||
class StormValueError(ValueError): | ||
pass | ||
|
||
|
||
class StormInvalidPortError(ValueError): | ||
pass |
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import unittest | ||
import os | ||
import getpass | ||
|
||
from storm import Storm | ||
from storm.ssh_uri_parser import parse | ||
from storm.exceptions import StormInvalidPortError | ||
|
||
|
||
class StormTests(unittest.TestCase): | ||
|
@@ -65,6 +68,25 @@ def test99_delete_all(self): | |
self.storm.delete_all_entries() | ||
self.assertEqual(len(self.storm.ssh_config.config_data), 0) | ||
|
||
def test_uri_parser(self): | ||
user = getpass.getuser() | ||
TEST_STRINGS = [ | ||
('[email protected]:22', ('root', 'emreyilmaz.me', 22)), | ||
('emreyilmaz.me', (user, 'emreyilmaz.me', 22)), | ||
('emreyilmaz.me:22', (user, 'emreyilmaz.me', 22)), | ||
('[email protected]', ('root', 'emreyilmaz.me', 22)) | ||
] | ||
|
||
for uri in TEST_STRINGS: | ||
self.assertEqual(parse(uri[0]), uri[1]) | ||
|
||
# false strings | ||
self.assertRaises(StormInvalidPortError, parse, '[email protected]:string-port') | ||
|
||
def test_search_host(self): | ||
results = self.storm.ssh_config.search_host("netsca") | ||
self.assertEqual(len(results), 1) | ||
|
||
def tearDown(self): | ||
os.unlink('/tmp/ssh_config') | ||
|
||
|