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 

15su = tools( 

16 arguments={"settingsFile": settingsFile}, 

17 docString=__doc__, 

18 logLevel="DEBUG", 

19 options_first=False, 

20 projectName=None, 

21 defaultSettingsFile=False 

22) 

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

24 

25# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA 

26moduleDirectory = os.path.dirname(__file__) 

27pathToInputDir = moduleDirectory + "/input/" 

28pathToOutputDir = moduleDirectory + "/output/" 

29 

30try: 

31 shutil.rmtree(pathToOutputDir) 

32except: 

33 pass 

34# COPY INPUT TO OUTPUT DIR 

35shutil.copytree(pathToInputDir, pathToOutputDir) 

36 

37# Recursively create missing directories 

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

39 os.makedirs(pathToOutputDir) 

40 

41# SETUP ALL DATABASE CONNECTIONS 

42from sherlock import database 

43db = database( 

44 log=log, 

45 settings=settings 

46) 

47dbConns, dbVersions = db.connect() 

48transientsDbConn = dbConns["transients"] 

49cataloguesDbConn = dbConns["catalogues"] 

50 

51class test_get_crossmatch_catalogues_column_map(unittest.TestCase): 

52 

53 def test_get_crossmatch_catalogues_column_map_function(self): 

54 

55 from sherlock.commonutils import get_crossmatch_catalogues_column_map 

56 colMaps = get_crossmatch_catalogues_column_map( 

57 log=log, 

58 dbConn=cataloguesDbConn 

59 ) 

60 

61 def test_get_crossmatch_catalogues_column_map_function_exception(self): 

62 

63 from sherlock.commonutils import get_crossmatch_catalogues_column_map 

64 try: 

65 this = get_crossmatch_catalogues_column_map( 

66 log=log, 

67 settings=settings, 

68 fakeKey="break the code" 

69 ) 

70 this.get() 

71 assert False 

72 except Exception as e: 

73 assert True 

74 print(str(e)) 

75 

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