850
850
('maas', 'mas', 'machines', 'list-allocated'))
851
851
self.assertEqual({}, ips)
853
def test_fabrics(self):
854
config = get_maas_env().config
855
account = MAASAccount(
856
config['name'], config['maas-server'], config['maas-oauth'])
857
with patch('subprocess.check_output', autospec=True,
858
return_value='[]') as co_mock:
859
fabrics = account.fabrics()
860
co_mock.assert_called_once_with(('maas', 'mas', 'fabrics', 'read'))
861
self.assertEqual([], fabrics)
863
def test_create_fabric(self):
864
config = get_maas_env().config
865
account = MAASAccount(
866
config['name'], config['maas-server'], config['maas-oauth'])
867
with patch('subprocess.check_output', autospec=True,
868
return_value='{"id": 1}') as co_mock:
869
fabric = account.create_fabric('a-fabric')
870
co_mock.assert_called_once_with((
871
'maas', 'mas', 'fabrics', 'create', 'name=a-fabric'))
872
self.assertEqual({'id': 1}, fabric)
874
fabric = account.create_fabric('a-fabric', class_type='something')
875
co_mock.assert_called_once_with((
876
'maas', 'mas', 'fabrics', 'create', 'name=a-fabric',
877
'class_type=something'))
878
self.assertEqual({'id': 1}, fabric)
880
def test_delete_fabric(self):
881
config = get_maas_env().config
882
account = MAASAccount(
883
config['name'], config['maas-server'], config['maas-oauth'])
884
with patch('subprocess.check_output', autospec=True,
885
return_value='') as co_mock:
886
result = account.delete_fabric(1)
887
co_mock.assert_called_once_with(
888
('maas', 'mas', 'fabric', 'delete', '1'))
889
self.assertEqual(None, result)
854
892
class TestMAAS1Account(TestCase):