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
11home = expanduser("~")
13packageDirectory = utKit("").get_project_root()
14# settingsFile = packageDirectory + "/test_settings.yaml"
15settingsFile = home + "/git_repos/_misc_/settings/marshall/test_settings.yaml"
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()
30 # SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA
31 moduleDirectory = os.path.dirname(__file__)
32 pathToInputDir = moduleDirectory + "/input/"
33 pathToOutputDir = moduleDirectory + "/output/"
35 try:
36 shutil.rmtree(pathToOutputDir)
37 except:
38 pass
39 # COPY INPUT TO OUTPUT DIR
40 shutil.copytree(pathToInputDir, pathToOutputDir)
42 # Recursively create missing directories
43 if not os.path.exists(pathToOutputDir):
44 os.makedirs(pathToOutputDir)
46 # COMMON STATUS CODES
47 # 200 OK
48 # 301 Moved Permanently
49 # 302 Found - possibly rediected
50 # 304 Not Modified
51 # 400 Bad Request
52 # 403 Forbidden
53 # 409 Conflict
54 # 401 Unauthorized
55 # 404 Not Found
56 # 405 Method Not Allowed
57 # 408 Request Timeout
58 # 429 Too Many Requests
59 # 500 Internal Server Error
60 # 504 Gateway Timeout
61 # 502 Bad Gateway
64class test_views_transients_akas(BaseTest):
66 def __init__(self, *args, **kwargs):
67 BaseTest.__init__(self, *args, **kwargs)
69 self.testIni = moduleDirectory + "/../../../test.ini#marshall_webapp"
70 self.testSettings = settings
71 self.settings = settings
73 def test_01_views_transients_akas_post(self):
74 # PARAM DICTIONARY = URL TOKENS
75 params = {}
77 # STATUS = 302 ... REDIRECT AFTER POST
78 respsonse = self.testapp.post(
79 "/transients/akas", params=params, status=404)
80 self.assertEqual(respsonse.status_code, 404)
82 def test_views_transients_akas_get(self):
83 # PARAM DICTIONARY = URL TOKENS
84 params = {}
86 params["format"] = "html"
87 respsonse = self.testapp.get('/transients/akas',
88 params=params, status=404)
89 print(respsonse)
90 self.assertEqual(respsonse.status_code, 404)
92 params["format"] = "json"
93 respsonse = self.testapp.get('/transients/akas',
94 params=params, status=200)
95 print(respsonse)
96 self.assertEqual(respsonse.status_code, 200)
97 params["format"] = "csv"
98 respsonse = self.testapp.get('/transients/akas',
99 params=params, status=200)
100 print(respsonse)
101 self.assertEqual(respsonse.status_code, 200)
102 params["format"] = "plain_table"
103 respsonse = self.testapp.get('/transients/akas',
104 params=params, status=200)
105 print(respsonse)
106 self.assertEqual(respsonse.status_code, 200)
108 def test_views_transients_akas_delete(self):
109 # PARAM DICTIONARY = URL TOKENS
110 params = {}
111 respsonse = self.testapp.delete('/transients/akas',
112 params=params, status=404)
113 print(respsonse)
114 self.assertEqual(respsonse.status_code, 404)
116 def test_views_transients_akas_put(self):
117 # PARAM DICTIONARY = URL TOKENS
118 params = {}
119 respsonse = self.testapp.put('/transients/akas',
120 params=params, status=404)
121 print(respsonse)
122 self.assertEqual(respsonse.status_code, 404)