def test_case_configvalue(self): gploader = gpload(['-f', os.path.join(os.path.dirname(__file__), 'allconfig.yml')]) self.assertEqual(u'test', gploader.getconfig('gpload:output:table')) self.assertEqual(1981, gploader.getconfig('gpload:input:source:port', int)) self.assertEqual(True, gploader.getconfig('gpload:preload:reuse_tables', bool)) self.assertEqual(False, gploader.getconfig('gpload:input:log_errors', bool, False)) self.assertEqual(True, gploader.getconfig('gpload:input:fully_qualified_domain_name', bool))
def test_case_configvalue(self): gploader = gpload(['-f', os.path.join(os.path.dirname(__file__), 'allconfig.yml')]) self.assertEqual('test', gploader.getconfig('gpload:output:table')) self.assertEqual(1981, gploader.getconfig('gpload:input:source:port', int)) self.assertEqual(True, gploader.getconfig('gpload:preload:reuse_tables', bool)) self.assertEqual(False, gploader.getconfig('gpload:input:log_errors', bool, False)) self.assertEqual(True, gploader.getconfig('gpload:input:fully_qualified_domain_name', bool))
def test_reuse_exttbl_with_errtbl_and_limit(self): gploader = gpload(['-f', os.path.join(os.path.dirname(__file__), 'gpload_merge.yml')]) gploader.read_config() gploader.locations = [ 'gpfdist://localhost:8080/test' ] rejectLimit = '9999' sql = gploader.get_reuse_exttable_query('csv', 'header', None, {}, None, False) self.assertTrue('pgext.fmterrtbl IS NULL' in sql) self.assertTrue('pgext.rejectlimit IS NULL' in sql)
def test_reuse_exttbl_with_logerrors_and_limit(self): gploader = gpload(['-f', os.path.join(os.path.dirname(__file__), 'gpload_merge.yml')]) gploader.read_config() gploader.locations = [ 'gpfdist://localhost:8080/test' ] rejectLimit = '9999' gploader.gpdb_version = "6.0.0" sql = gploader.get_reuse_exttable_query('csv', 'header', None, {}, None, False, None) self.assertTrue("pgext.logerrors='f'" in sql) self.assertTrue('pgext.rejectlimit IS NULL' in sql)
def help_test_with_config(self, gpload_param, expected_begin_value, expected_commit_value): print(gpload_param) gploader = gpload(gpload_param) gploader.read_config() gploader.db = self gploader.db.query = Mock(side_effect=self.mockQuery) gploader.do_method_merge = Mock(side_effect=self.mockDoNothing) gploader.do_method_update = Mock(side_effect=self.mockDoNothing) gploader.do_method_insert = Mock(side_effect=self.mockDoNothing) gploader.do_method() self.assertEqual(self.begin, expected_begin_value) self.assertEqual(self.commit, expected_commit_value)
def help_test_with_config(self, gpload_param, expected_begin_value, expected_commit_value): print gpload_param gploader = gpload(gpload_param) gploader.read_config() gploader.db = self gploader.db.query = Mock(side_effect=self.mockQuery) gploader.do_method_merge = Mock(side_effect=self.mockDoNothing) gploader.do_method_update = Mock(side_effect=self.mockDoNothing) gploader.do_method_insert = Mock(side_effect=self.mockDoNothing) gploader.do_method() self.assertEqual(self.begin, expected_begin_value) self.assertEqual(self.commit, expected_commit_value)
def test_reuse_exttbl_with_errtbl_and_limit(self): gploader = gpload([ '-f', os.path.join(os.path.dirname(__file__), 'gpload_merge.yml') ]) gploader.read_config() gploader.locations = ['gpfdist://localhost:8080/test'] rejectLimit = '9999' errTableOid = 12345 sql = gploader.get_reuse_exttable_query('csv', 'header', rejectLimit, errTableOid, {}, None, False) self.assertTrue('12345' in sql) self.assertTrue(rejectLimit in sql) sql = gploader.get_reuse_exttable_query('csv', 'header', None, None, {}, None, False) self.assertTrue('pgext.fmterrtbl IS NULL' in sql) self.assertTrue('pgext.rejectlimit IS NULL' in sql)