def test_list_ebs_volumes_regexp(self): conn = Mock() conn.get_all_volumes = Mock(return_value=self.volume_list) days = 0 regexp = 'i-\d.+' filtered_volumes = list_ebs_volumes(conn, days, regexp) for v in filtered_volumes: self.assertTrue(re.match(regexp, v.tags['Name'])) conn.get_all_volumes.assert_called_once() conn.get_all_volumes.reset_mock() days = 5 filtered_volumes = list_ebs_volumes(conn, days, regexp) self.assertEqual(4, len(filtered_volumes)) for v in filtered_volumes: self.assertTrue(re.match(regexp, v.tags['Name'])) conn.get_all_volumes.assert_called_once()
def test_list_ebs_volumes_no_regexp(self): conn = Mock() conn.get_all_volumes = Mock(return_value=self.volume_list) conn.get_all_volumes.assert_called_once() conn.get_all_volumes.reset_mock() days = 0 self.assertEqual(self.volume_list, list_ebs_volumes(conn, days)) conn.get_all_volumes.assert_called_once() conn.get_all_volumes.reset_mock() days = 13 self.assertEqual([], list_ebs_volumes(conn, days)) conn.get_all_volumes.assert_called_once() conn.get_all_volumes.reset_mock() days = 5 filtered_volumes = list_ebs_volumes(conn, days) self.assertEqual(8, len(filtered_volumes)) conn.get_all_volumes.assert_called_once() conn.get_all_volumes.reset_mock()