Exemplo n.º 1
0
 def test_ruleset_addmeta_file(self, get_session):
     params = {
         "rulesetname": 'File Ruleset1',
         "metaname": 'TESTFILE',
         "custom_sql": None,
         "where_clause": None,
         "having_clause": None,
         "key_column": None,
         "file_format": 'testformat',
         "file_delimiter": ',',
         "file_eor": 'linux',
         "file_enclosure": '"',
         "file_name_regex": None,
         "file_eor_custom": None,
         "envname": 'Env1'
     }
     with mock.patch.object(FileMetadataApi,
                            'create_file_metadata',
                            return_value=FileMetadata(
                                file_metadata_id=124,
                                file_name="TESTFILE",
                                ruleset_id=1)) as mock_method:
         ret = ruleset_addmeta(None, params, None)
         name, args, kwargs = mock_method.mock_calls[0]
         print args[0]
         self.assertEqual("TESTFILE", args[0].file_name)
         self.assertEqual(1, args[0].file_format_id)
         self.assertEqual(2, args[0].ruleset_id)
         self.assertEqual('\n', args[0].end_of_record)
         self.assertEqual(0, ret)
Exemplo n.º 2
0
 def test_ruleset_addmeta(self, get_session):
     params = {
         "rulesetname": 'DB Ruleset1',
         "metaname": 'TESTTABLE',
         "custom_sql": None,
         "where_clause": 'id>1000',
         "having_clause": None,
         "key_column": None,
         "file_format": None,
         "file_delimiter": None,
         "file_eor": None,
         "file_enclosure": None,
         "file_name_regex": None,
         "file_eor_custom": None,
         "envname": 'Env1'
     }
     with mock.patch.object(TableMetadataApi,
                            'create_table_metadata',
                            return_value=TableMetadata(
                                table_metadata_id=123,
                                table_name="TESTTABLE",
                                ruleset_id=1)) as mock_method:
         ret = ruleset_addmeta(None, params, None)
         name, args, kwargs = mock_method.mock_calls[0]
         print args[0]
         self.assertEqual("TESTTABLE", args[0].table_name)
         self.assertEqual("id>1000", args[0].where_clause)
         self.assertEqual(1, args[0].ruleset_id)
         self.assertEqual(0, ret)
Exemplo n.º 3
0
    def test_ruleset_addmetafromfetch_bulk(self, get_session):
        params = {
            "rulesetname": 'DB Ruleset1',
            "metaname": None,
            "envname": 'Env1',
            "fetchfilter": None
        }

        c = {'table_metadata': [{'custom_sql': None,
                     'having_clause': None,
                     'key_column': None,
                     'ruleset_id': 1,
                     'table_metadata_id': None,
                     'table_name': 'DEPT',
                     'where_clause': None},
                    {'custom_sql': None,
                     'having_clause': None,
                     'key_column': None,
                     'ruleset_id': 1,
                     'table_metadata_id': None,
                     'table_name': 'EMP',
                     'where_clause': None}]}

        with mock.patch.object(
                DatabaseRulesetApi, 'bulk_table_update',
                return_value=AsyncTask(async_task_id=1)) as mock_method:
            ret = ruleset_addmeta(None, params, None, True, True)
            retval = mock_method.call_args_list
            self.assertDictEqual(retval[0][0][1].to_dict(), c)
            self.assertEqual(ret, 0)
Exemplo n.º 4
0
 def test_ruleset_addmetafromfetch_exception(self, get_session):
     params = {
         "rulesetname": 'DB Ruleset1',
         "metaname": None,
         "envname": 'Env1',
         "fetchfilter": None
     }
     with mock.patch.object(
             TableMetadataApi, 'create_table_metadata', 
             new=create_table_fromfetch):
         ret = ruleset_addmeta(None, params, None, True, False)
         self.assertNotEqual(ret, 0)
Exemplo n.º 5
0
 def test_ruleset_addmetafromfetch(self, get_session):
     params = {
         "rulesetname": 'DB Ruleset1',
         "metaname": None,
         "envname": 'Env1',
         "fetchfilter": None
     }
     with mock.patch.object(
             TableMetadataApi, 'create_table_metadata') as mock_method:
         ret = ruleset_addmeta(None, params, None, True, False)
         retval = mock_method.call_args_list
         self.assertEqual(retval[0][0][0].table_name, 'DEPT')
         self.assertEqual(retval[1][0][0].table_name, 'EMP')
         self.assertEqual(ret, 0)