return_value=DatabaseRuleset( database_ruleset_id=100, ruleset_name="newdbrule", )) as mock_ruleset, \ mock.patch.object( TableMetadataApi, 'create_table_metadata', new=createtable), \ mock.patch.object( ColumnMetadataApi, 'update_column_metadata', return_value=None) as mock_column: ret = ruleset_clone(None, 'DB Ruleset1', None, "New ruleset") name, args, kwargs = mock_ruleset.mock_calls[0] print args self.assertEqual(100, args[0].database_ruleset_id) name, args, kwargs = mock_column.mock_calls[0] print args self.assertEqual(args[1].table_metadata_id, 101) self.assertEqual(args[1].column_metadata_id, 1) self.assertEqual(args[1].algorithm_name, "LastNameLookup") name, args, kwargs = mock_column.mock_calls[1] print args self.assertEqual(args[1].table_metadata_id, 102) self.assertEqual(args[1].column_metadata_id, 1) self.assertEqual(args[1].algorithm_name, "TestNameLookup") self.assertEqual(0, ret) if __name__ == '__main__': logging_est('test.log', False) main(buffer=True, verbosity=2)
new=fileconnector_load) @mock.patch.object(TableMetadataApi, 'get_all_table_metadata', new=tablemeta_load) @mock.patch.object(FileMetadataApi, 'get_all_file_metadata', new=filemeta_load) @mock.patch.object(TableMetadataApi, 'delete_table_metadata', new=retok) @mock.patch.object(FileFormatApi, 'get_all_file_formats', new=fileformat_load) @mock.patch.object(DatabaseRulesetApi, 'delete_database_ruleset', new=retok) @mock.patch.object(ColumnMetadataApi, 'get_all_column_metadata', new=meta_load) @mock.patch.object(FileFieldMetadataApi, 'get_all_file_field_metadata', new=filefieldmeta_load) class TestRuleset(TestCase): def test_column_list(self, get_session): column_list(None, "csv", None, None, None, None, None, None, None) if not hasattr(sys.stdout, "getvalue"): self.fail("need to run in buffered mode") output = sys.stdout.getvalue().strip() self.assertEquals( output, '#Engine name,Environment name,Ruleset name,Metadata name,' 'Column name,Type,Data type,Domain name,Alg name\r\ntesteng,Env1,DB Ruleset1,EMP,' 'ENAME,FK,VARCHAR2(30),LAST_NAME,LastNameLookup\r\ntesteng,Env1,DB Ruleset1,DEPT,' 'DNAME,IX,VARCHAR2(66),TEST_NAME,TestNameLookup\r\ntesteng,Env1,File Ruleset1,FILE,Col1,,pos 1,,' ) if __name__ == '__main__': logging_est('test.log', True) main(buffer=True, verbosity=2)