Commit ecd35a12 by Simon János

Revert "getitem and delitem implemented on resource group"

This reverts commit 9c6303cc
parent cd57400f
Pipeline #286 passed with stage
in 31 seconds
...@@ -130,12 +130,6 @@ class ResourceGroup(Resource): ...@@ -130,12 +130,6 @@ class ResourceGroup(Resource):
except InvalidResourceException: except InvalidResourceException:
del self.__resources[resource.id] del self.__resources[resource.id]
def __getitem__(self, resource_id):
return self.__resources[resource_id]
def __delitem__(self, resource_id):
self.remove(self[resource_id])
@property @property
def resources(self): def resources(self):
return list(self.__resources.values()) return list(self.__resources.values())
......
from __future__ import print_function
import copy import copy
import json import json
from unittest.case import TestCase from unittest.case import TestCase
...@@ -210,40 +208,7 @@ class ResourceGroupTest(TestCase): ...@@ -210,40 +208,7 @@ class ResourceGroupTest(TestCase):
# then # then
self.assertEqual([], group.resources) self.assertEqual([], group.resources)
def test_resource_group_del_item_by_id(self): # @skip('works same way as resource addition')
# given
expected_resource_id = 'some_resource'
expected_resource = Instance(id=expected_resource_id)
group = ResourceGroup(resources=[expected_resource])
# when
del group[expected_resource_id]
# then
self.assertNotIn(expected_resource, group.resources)
def test_resource_group_del_invalid_id(self):
# given
group = ResourceGroup()
# then
with self.assertRaises(KeyError):
del group['invalid_resource_id']
def test_resource_group_get_item_by_id(self):
# given
expected_resource_id = 'some_resource'
expected_resource = Instance(id=expected_resource_id)
group = ResourceGroup(resources=[expected_resource])
# when
result = group[expected_resource_id]
# then
self.assertEqual(expected_resource, result)
with self.assertRaises(KeyError):
print(group['invalid_resource_id'])
def test_resource_group_addition(self): def test_resource_group_addition(self):
# given # given
group1 = ResourceGroup() group1 = ResourceGroup()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment