Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from __future__ import print_function 

2from builtins import str 

3import os 

4import unittest 

5import shutil 

6import unittest 

7import yaml 

8from fundamentals.utKit import utKit 

9from fundamentals import tools 

10from os.path import expanduser 

11home = expanduser("~") 

12 

13packageDirectory = utKit("").get_project_root() 

14settingsFile = packageDirectory + "/test_settings.yaml" 

15# settingsFile = home + "/.config/soxspipe.recipes/soxspipe.recipes.yaml" 

16su = tools( 

17 arguments={"settingsFile": settingsFile}, 

18 docString=__doc__, 

19 logLevel="DEBUG", 

20 options_first=False, 

21 projectName=None, 

22 defaultSettingsFile=False 

23) 

24arguments, settings, log, dbConn = su.setup() 

25 

26# SETUP AND TEARDOWN FIXTURE FUNCTIONS FOR THE ENTIRE MODULE 

27moduleDirectory = os.path.dirname(__file__) 

28utKit = utKit(moduleDirectory) 

29log, dbConn, pathToInputDir, pathToOutputDir = utKit.setupModule() 

30utKit.tearDownModule() 

31 

32try: 

33 shutil.rmtree(pathToOutputDir) 

34except: 

35 pass 

36# COPY INPUT TO OUTPUT DIR 

37shutil.copytree(pathToInputDir, pathToOutputDir) 

38 

39# Recursively create missing directories 

40if not os.path.exists(pathToOutputDir): 

41 os.makedirs(pathToOutputDir) 

42 

43class test_table_exists(unittest.TestCase): 

44 

45 def test_table_exists_function(self): 

46 

47 from fundamentals.mysql import writequery 

48 sqlQuery = "CREATE TABLE IF NOT EXISTS `testing_table` (`id` INT NOT NULL, PRIMARY KEY (`id`))" 

49 writequery( 

50 log=log, 

51 sqlQuery=sqlQuery, 

52 dbConn=dbConn, 

53 Force=False, 

54 manyValueList=False 

55 ) 

56 

57 from fundamentals.mysql import table_exists 

58 tableName = "testing_table" 

59 this = table_exists( 

60 dbConn=dbConn, 

61 log=log, 

62 dbTableName=tableName 

63 ) 

64 # print("%(tableName)s exists: %(this)s" % locals()) 

65 

66 from fundamentals.mysql import writequery 

67 sqlQuery = "DROP TABLE `testing_table`;" 

68 writequery( 

69 log=log, 

70 sqlQuery=sqlQuery, 

71 dbConn=dbConn, 

72 Force=False, 

73 manyValueList=False 

74 ) 

75 

76 def test_table_exists_function02(self): 

77 

78 from fundamentals.mysql import table_exists 

79 tableName = "stupid_named_table" 

80 this = table_exists( 

81 dbConn=dbConn, 

82 log=log, 

83 dbTableName=tableName 

84 ) 

85 # print("%(tableName)s exists: %(this)s" % locals()) 

86 

87 # x-print-testpage-for-pessto-marshall-web-object 

88 

89 # x-class-to-test-named-worker-function