Skip to content

Commit

Permalink
Merge branch 'master' into issues/35
Browse files Browse the repository at this point in the history
* master:
  Add profile add command line and associated tests. Closes #34. (#54)

# Conflicts:
#	quipucords/cli/cli.py
#	quipucords/cli/network/tests_add.py
  • Loading branch information
chambridge committed Sep 28, 2017
2 parents f9d2ce6 + ddebb69 commit def7289
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions quipucords/cli/network/tests_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def test_add_network_name_dup(self):
with requests_mock.Mocker() as mocker:
mocker.get(get_auth_url, status_code=200, json=get_auth_data)
mocker.post(post_network_url, status_code=400, json=error)
aac = NetworkAddCommand(SUBPARSER)
nac = NetworkAddCommand(SUBPARSER)
args = Namespace(name='net_dup', auth=['auth1'], hosts=['1.2.3.4'],
ssh_port=22)
with self.assertRaises(SystemExit):
with redirect_stdout(net_out):
aac.main(args)
aac.main(args)
nac.main(args)
nac.main(args)
self.assertTrue('profile with this name already exists.'
in net_out.getvalue())

Expand All @@ -107,13 +107,13 @@ def test_add_network_auth_less(self):
get_auth_data = [{'id': 1, 'name': 'auth1'}]
with requests_mock.Mocker() as mocker:
mocker.get(get_auth_url, status_code=200, json=get_auth_data)
aac = NetworkAddCommand(SUBPARSER)
nac = NetworkAddCommand(SUBPARSER)
args = Namespace(name='net1', auth=['auth1', 'auth2'],
hosts=['1.2.3.4'],
ssh_port=22)
with self.assertRaises(SystemExit):
with redirect_stdout(net_out):
aac.main(args)
nac.main(args)
self.assertTrue('An error occurred while processing '
'the "--auth" input'
in net_out.getvalue())
Expand All @@ -125,13 +125,13 @@ def test_add_network_auth_err(self):
get_auth_url = BASE_URL + AUTH_URI + '?name=auth1%2Cauth2'
with requests_mock.Mocker() as mocker:
mocker.get(get_auth_url, status_code=500)
aac = NetworkAddCommand(SUBPARSER)
nac = NetworkAddCommand(SUBPARSER)
args = Namespace(name='net1', auth=['auth1', 'auth2'],
hosts=['1.2.3.4'],
ssh_port=22)
with self.assertRaises(SystemExit):
with redirect_stdout(net_out):
aac.main(args)
nac.main(args)
self.assertTrue('An error occurred while processing '
'the "--auth" input'
in net_out.getvalue())
Expand All @@ -143,12 +143,12 @@ def test_add_network_ssl_err(self):
get_auth_url = BASE_URL + AUTH_URI + '?name=auth1'
with requests_mock.Mocker() as mocker:
mocker.get(get_auth_url, exc=requests.exceptions.SSLError)
aac = NetworkAddCommand(SUBPARSER)
nac = NetworkAddCommand(SUBPARSER)
args = Namespace(name='net1', auth=['auth1'], hosts=['1.2.3.4'],
ssh_port=22)
with self.assertRaises(SystemExit):
with redirect_stdout(net_out):
aac.main(args)
nac.main(args)
self.assertEqual(net_out.getvalue(), SSL_ERROR_MSG)

def test_add_network_conn_err(self):
Expand All @@ -158,12 +158,12 @@ def test_add_network_conn_err(self):
get_auth_url = BASE_URL + AUTH_URI + '?name=auth1'
with requests_mock.Mocker() as mocker:
mocker.get(get_auth_url, exc=requests.exceptions.ConnectTimeout)
aac = NetworkAddCommand(SUBPARSER)
nac = NetworkAddCommand(SUBPARSER)
args = Namespace(name='net1', auth=['auth1'], hosts=['1.2.3.4'],
ssh_port=22)
with self.assertRaises(SystemExit):
with redirect_stdout(net_out):
aac.main(args)
nac.main(args)
self.assertEqual(net_out.getvalue(), CONNECTION_ERROR_MSG)

def test_add_network(self):
Expand All @@ -176,10 +176,10 @@ def test_add_network(self):
with requests_mock.Mocker() as mocker:
mocker.get(get_auth_url, status_code=200, json=get_auth_data)
mocker.post(post_network_url, status_code=201)
aac = NetworkAddCommand(SUBPARSER)
nac = NetworkAddCommand(SUBPARSER)
args = Namespace(name='net1', auth=['auth1'], hosts=['1.2.3.4'],
ssh_port=22)
with redirect_stdout(net_out):
aac.main(args)
nac.main(args)
self.assertEqual(net_out.getvalue(),
'Profile "net1" was added\n')

0 comments on commit def7289

Please sign in to comment.