Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1386)

Unified Diff: third_party/boto/tests/unit/ec2/test_networkinterface.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/boto/tests/unit/ec2/test_networkinterface.py
===================================================================
--- third_party/boto/tests/unit/ec2/test_networkinterface.py (revision 33376)
+++ third_party/boto/tests/unit/ec2/test_networkinterface.py (working copy)
@@ -21,14 +21,88 @@
# IN THE SOFTWARE.
#
+import mock
from tests.unit import unittest
from boto.exception import BotoClientError
from boto.ec2.networkinterface import NetworkInterfaceCollection
from boto.ec2.networkinterface import NetworkInterfaceSpecification
from boto.ec2.networkinterface import PrivateIPAddress
+from boto.ec2.networkinterface import Attachment, NetworkInterface
+class NetworkInterfaceTests(unittest.TestCase):
+ def setUp(self):
+
+ self.attachment = Attachment()
+ self.attachment.id = 'eni-attach-1'
+ self.attachment.instance_id = 10
+ self.attachment.status = "some status"
+ self.attachment.device_index = 100
+
+ self.eni_one = NetworkInterface()
+ self.eni_one.id = 'eni-1'
+ self.eni_one.status = "one_status"
+ self.eni_one.attachment = self.attachment
+
+ self.eni_two = NetworkInterface()
+ self.eni_two.connection = mock.Mock()
+ self.eni_two.id = 'eni-2'
+ self.eni_two.status = "two_status"
+ self.eni_two.attachment = None
+
+ def test_update_with_validate_true_raises_value_error(self):
+ self.eni_one.connection = mock.Mock()
+ self.eni_one.connection.get_all_network_interfaces.return_value = []
+ with self.assertRaisesRegexp(ValueError, "^eni-1 is not a valid ENI ID$"):
+ self.eni_one.update(True)
+
+ def test_update_with_result_set_greater_than_0_updates_dict(self):
+ self.eni_two.connection.get_all_network_interfaces.return_value = [self.eni_one]
+ self.eni_two.update()
+
+ assert all([self.eni_two.status == "one_status",
+ self.eni_two.id == 'eni-1',
+ self.eni_two.attachment == self.attachment])
+
+ def test_update_returns_status(self):
+ self.eni_one.connection = mock.Mock()
+ self.eni_one.connection.get_all_network_interfaces.return_value = [self.eni_two]
+ retval = self.eni_one.update()
+ self.assertEqual(retval, "two_status")
+
+ def test_attach_calls_attach_eni(self):
+ self.eni_one.connection = mock.Mock()
+ self.eni_one.attach("instance_id", 11)
+ self.eni_one.connection.attach_network_interface.assert_called_with(
+ 'eni-1',
+ "instance_id",
+ 11,
+ dry_run=False
+ )
+
+ def test_detach_calls_detach_network_interface(self):
+ self.eni_one.connection = mock.Mock()
+ self.eni_one.detach()
+ self.eni_one.connection.detach_network_interface.assert_called_with(
+ 'eni-attach-1',
+ False,
+ dry_run=False
+ )
+
+ def test_detach_with_no_attach_data(self):
+ self.eni_two.connection = mock.Mock()
+ self.eni_two.detach()
+ self.eni_two.connection.detach_network_interface.assert_called_with(
+ None, False, dry_run=False)
+
+ def test_detach_with_force_calls_detach_network_interface_with_force(self):
+ self.eni_one.connection = mock.Mock()
+ self.eni_one.detach(True)
+ self.eni_one.connection.detach_network_interface.assert_called_with(
+ 'eni-attach-1', True, dry_run=False)
+
+
class TestNetworkInterfaceCollection(unittest.TestCase):
maxDiff = None
« no previous file with comments | « third_party/boto/tests/unit/ec2/test_instancetype.py ('k') | third_party/boto/tests/unit/ec2/test_snapshot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698