~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to tests/test_substrate.py

  • Committer: Martin Packman
  • Date: 2016-09-20 13:09:48 UTC
  • mto: This revision was merged to the branch mainline in revision 1610.
  • Revision ID: martin.packman@canonical.com-20160920130948-tz5wa98eygbo3t1o
Add methods for managing fabrics to maas account substrate

Show diffs side-by-side

added added

removed removed

Lines of Context:
850
850
            ('maas', 'mas', 'machines', 'list-allocated'))
851
851
        self.assertEqual({}, ips)
852
852
 
 
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)
 
862
 
 
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)
 
873
            co_mock.reset_mock()
 
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)
 
879
 
 
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)
 
890
 
853
891
 
854
892
class TestMAAS1Account(TestCase):
855
893