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 yaml 

7from sherlock.utKit import utKit 

8from fundamentals import tools 

9from os.path import expanduser 

10home = expanduser("~") 

11 

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

13settingsFile = packageDirectory + "/test_settings.yaml" 

14 

15print(settingsFile) 

16 

17su = tools( 

18 arguments={"settingsFile": settingsFile}, 

19 docString=__doc__, 

20 logLevel="DEBUG", 

21 options_first=False, 

22 projectName=None, 

23 defaultSettingsFile=False 

24) 

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

26 

27# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA 

28moduleDirectory = os.path.dirname(__file__) 

29pathToInputDir = moduleDirectory + "/input/" 

30pathToOutputDir = moduleDirectory + "/output/" 

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 

43# SETUP ALL DATABASE CONNECTIONS 

44from sherlock import database 

45db = database( 

46 log=log, 

47 settings=settings 

48) 

49dbConns, dbVersions = db.connect() 

50transientsDbConn = dbConns["transients"] 

51cataloguesDbConn = dbConns["catalogues"] 

52 

53# class test_update_wiki_pages(unittest.TestCase): 

54 

55# def test_update_wiki_pages_function(self): 

56 

57# from sherlock.commonutils import update_wiki_pages 

58# wiki = update_wiki_pages( 

59# log=log, 

60# settings=settings 

61# ) 

62# wiki.update() 

63 

64# def test_update_wiki_pages_function_exception(self): 

65 

66# from sherlock.commonutils import update_wiki_pages 

67# try: 

68# this = update_wiki_pages( 

69# log=log, 

70# settings=settings, 

71# fakeKey="break the code" 

72# ) 

73# this.update() 

74# assert False 

75# except Exception as e: 

76# assert True 

77# print(str(e)) 

78 

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