def test_present_nocreation(self):
     with patch.dict(
             postgres_schema.__salt__,
         {
             "postgres.schema_get":
             Mock(return_value={"foo": {
                 "acl": "",
                 "owner": "postgres"
             }}),
             "postgres.schema_create":
             MagicMock(),
         },
     ):
         ret = postgres_schema.present("dbname", "foo")
         self.assertEqual(
             ret,
             {
                 "comment": "Schema foo already exists in database dbname",
                 "changes": {},
                 "dbname": "dbname",
                 "name": "foo",
                 "result": True,
             },
         )
         self.assertEqual(
             self.salt_stub["postgres.schema_create"].call_count, 0)
Exemple #2
0
 def test_present_creation(self):
     with patch.dict(
             postgres_schema.__salt__,
         {
             "postgres.schema_get": Mock(return_value=None),
             "postgres.schema_create": MagicMock(),
         },
     ):
         ret = postgres_schema.present("dbname", "foo")
         self.assertEqual(
             ret,
             {
                 "comment":
                 "Schema foo has been created in database dbname",
                 "changes": {
                     "foo": "Present"
                 },
                 "dbname": "dbname",
                 "name": "foo",
                 "result": True,
             },
         )
         self.assertEqual(
             postgres_schema.__salt__["postgres.schema_create"].call_count,
             1)
Exemple #3
0
 def test_present_nocreation(self):
     ret = postgres_schema.present('dbname', 'foo')
     self.assertEqual(
         ret,
         {'comment': 'Schema foo already exists in database dbname',
          'changes': {},
          'dbname': 'dbname',
          'name': 'foo',
          'result': True}
         )
     self.assertEqual(SALT_STUB['postgres.schema_create'].call_count, 0)
Exemple #4
0
 def test_present_creation(self):
     ret = postgres_schema.present('dbname', 'foo')
     self.assertEqual(
         ret,
         {'comment': 'Schema foo has been created in database dbname',
          'changes': {'foo': 'Present'},
          'dbname': 'dbname',
          'name': 'foo',
          'result': True}
         )
     self.assertEqual(SALT_STUB['postgres.schema_create'].call_count, 1)
Exemple #5
0
 def test_present_nocreation(self):
     ret = postgres_schema.present('dbname', 'foo')
     self.assertEqual(
         ret, {
             'comment': 'Schema foo already exists in database dbname',
             'changes': {},
             'dbname': 'dbname',
             'name': 'foo',
             'result': True
         })
     self.assertEqual(SALT_STUB['postgres.schema_create'].call_count, 0)
Exemple #6
0
 def test_present_creation(self):
     ret = postgres_schema.present('dbname', 'foo')
     self.assertEqual(
         ret,
         {'comment': 'Schema foo has been created in database dbname',
          'changes': {'foo': 'Present'},
          'dbname': 'dbname',
          'name': 'foo',
          'result': True}
         )
     self.assertEqual(SALT_STUB['postgres.schema_create'].call_count, 1)
Exemple #7
0
 def test_present_creation(self):
     with patch.dict(postgres_schema.__salt__, {'postgres.schema_get': Mock(return_value=None),
                                                'postgres.schema_create': MagicMock()}):
         ret = postgres_schema.present('dbname', 'foo')
         self.assertEqual(
             ret,
             {'comment': 'Schema foo has been created in database dbname',
              'changes': {'foo': 'Present'},
              'dbname': 'dbname',
              'name': 'foo',
              'result': True}
             )
         self.assertEqual(self.salt_stub['postgres.schema_create'].call_count, 1)
Exemple #8
0
 def test_present_nocreation(self):
     with patch.dict(postgres_schema.__salt__, {
                         'postgres.schema_get': Mock(return_value={'foo':
                                                                   {'acl': '',
                                                                    'owner': 'postgres'}
                                                                   }),
                         'postgres.schema_create': MagicMock()}):
         ret = postgres_schema.present('dbname', 'foo')
         self.assertEqual(
             ret,
             {'comment': 'Schema foo already exists in database dbname',
              'changes': {},
              'dbname': 'dbname',
              'name': 'foo',
              'result': True}
             )
         self.assertEqual(self.salt_stub['postgres.schema_create'].call_count, 0)
Exemple #9
0
    def test_present(self):
        '''
        Test to ensure that the named schema is present in the database.
        '''
        name = 'myname'
        dbname = 'mydb'

        ret = {'name': name,
               'dbname': dbname,
               'changes': {},
               'result': True,
               'comment': ''}

        mock = MagicMock(return_value=name)
        with patch.dict(postgres_schema.__salt__,
                        {'postgres.schema_get': mock}):
            comt = ('Schema {0} already exists in database {1}'.format(name,
                                                                       dbname))
            ret.update({'comment': comt})
            self.assertDictEqual(postgres_schema.present(dbname, name), ret)
Exemple #10
0
    def test_present(self):
        '''
        Test to ensure that the named schema is present in the database.
        '''
        name = 'myname'
        dbname = 'mydb'

        ret = {'name': name,
               'dbname': dbname,
               'changes': {},
               'result': True,
               'comment': ''}

        mock = MagicMock(return_value=name)
        with patch.dict(postgres_schema.__salt__,
                        {'postgres.schema_get': mock}):
            comt = ('Schema {0} already exists in database {1}'.format(name,
                                                                       dbname))
            ret.update({'comment': comt})
            self.assertDictEqual(postgres_schema.present(dbname, name), ret)
Exemple #11
0
    def test_present(self):
        """
        Test to ensure that the named schema is present in the database.
        """
        name = "myname"
        dbname = "mydb"

        ret = {
            "name": name,
            "dbname": dbname,
            "changes": {},
            "result": True,
            "comment": "",
        }

        mock = MagicMock(return_value=name)
        with patch.dict(postgres_schema.__salt__,
                        {"postgres.schema_get": mock}):
            with patch.dict(postgres_schema.__opts__, {"test": False}):
                comt = "Schema {0} already exists in database {1}".format(
                    name, dbname)
                ret.update({"comment": comt})
                self.assertDictEqual(postgres_schema.present(dbname, name),
                                     ret)