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 marshall_webapp.utKit import utKit 

8from fundamentals import tools 

9from os.path import expanduser 

10from dryxPyramid.utKit import BaseTest 

11 

12home = expanduser("~") 

13 

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

15# settingsFile = packageDirectory + "/test_settings.yaml" 

16settingsFile = home + "/git_repos/_misc_/settings/marshall/test_settings.yaml" 

17 

18exists = os.path.exists(settingsFile) 

19if exists: 

20 su = tools( 

21 arguments={"settingsFile": settingsFile}, 

22 docString=__doc__, 

23 logLevel="DEBUG", 

24 options_first=False, 

25 projectName=None, 

26 defaultSettingsFile=False 

27 ) 

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

29 

30 # SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA 

31 moduleDirectory = os.path.dirname(__file__) 

32 pathToInputDir = moduleDirectory + "/input/" 

33 pathToOutputDir = moduleDirectory + "/output/" 

34 

35 try: 

36 shutil.rmtree(pathToOutputDir) 

37 except: 

38 pass 

39 # COPY INPUT TO OUTPUT DIR 

40 shutil.copytree(pathToInputDir, pathToOutputDir) 

41 

42 # Recursively create missing directories 

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

44 os.makedirs(pathToOutputDir) 

45 

46 

47class test_views_services_calendars(BaseTest): 

48 

49 def __init__(self, *args, **kwargs): 

50 BaseTest.__init__(self, *args, **kwargs) 

51 

52 self.testIni = moduleDirectory + "/../../../test.ini#marshall_webapp" 

53 self.testSettings = settings 

54 self.settings = settings 

55 

56 def test_views_services_calendars_get(self): 

57 params = {} 

58 

59 respsonse = self.testapp.get('/calendars', 

60 params=params) 

61 print(respsonse) 

62 self.assertEqual(respsonse.status_code, 200) 

63 

64 params["format"] = "json" 

65 respsonse = self.testapp.get('/calendars', 

66 params=params, status=404) 

67 print(respsonse) 

68 self.assertEqual(respsonse.status_code, 404) 

69 

70 params["format"] = "csv" 

71 respsonse = self.testapp.get('/calendars', 

72 params=params, status=404) 

73 print(respsonse) 

74 self.assertEqual(respsonse.status_code, 404) 

75 params["format"] = "plain_table" 

76 respsonse = self.testapp.get('/calendars', 

77 params=params, status=404) 

78 print(respsonse) 

79 self.assertEqual(respsonse.status_code, 404) 

80 

81 def test_views_services_calendars_post(self): 

82 params = {} 

83 # STATUS = 302 ... REDIRECT AFTER POST 

84 respsonse = self.testapp.post( 

85 "/calendars", params=params, status=404) 

86 print(respsonse) 

87 self.assertEqual(respsonse.status_code, 404) 

88 

89 def test_views_services_calendars_delete(self): 

90 # PARAM DICTIONARY = URL TOKENS 

91 params = {} 

92 respsonse = self.testapp.delete('/calendars', 

93 params=params, status=404) 

94 print(respsonse) 

95 self.assertEqual(respsonse.status_code, 404) 

96 

97 def test_views_services_calendars_put(self): 

98 # PARAM DICTIONARY = URL TOKENS 

99 params = {} 

100 respsonse = self.testapp.put('/calendars', 

101 params=params, status=404) 

102 print(respsonse) 

103 self.assertEqual(respsonse.status_code, 404)