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 + \
16 "/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_elements_akas(BaseTest):
66 def __init__(self, *args, **kwargs):
67 BaseTest.__init__(self, *args, **kwargs)
69 # xt-setup-unit-testing-files-and-folders
71 self.testIni = moduleDirectory + "/../../../test.ini#marshall_webapp"
73 self.testSettings = settings
74 self.settings = settings
76 def test_views_transients_element_akas_get(self):
77 # PARAM DICTIONARY = URL TOKENS
78 params = {}
80 params["format"] = "html"
81 respsonse = self.testapp.get('/transients/1/akas',
82 params=params, status=404)
83 print(respsonse)
84 self.assertEqual(respsonse.status_code, 404)
86 params["format"] = "json"
87 respsonse = self.testapp.get('/transients/1/akas',
88 params=params, status=200)
89 print(respsonse)
90 self.assertEqual(respsonse.status_code, 200)
91 params["format"] = "csv"
92 respsonse = self.testapp.get('/transients/1/akas',
93 params=params, status=200)
94 print(respsonse)
95 self.assertEqual(respsonse.status_code, 200)
96 params["format"] = "plain_table"
97 respsonse = self.testapp.get('/transients/1/akas',
98 params=params, status=200)
99 print(respsonse)
100 self.assertEqual(respsonse.status_code, 200)
101 params["format"] = None
102 respsonse = self.testapp.get('/transients/1/akas',
103 params=params, status=200)
104 print(respsonse)
105 self.assertEqual(respsonse.status_code, 200)
107 def test_views_transients_element_akas_post(self):
108 # PARAM DICTIONARY = URL TOKENS
109 params = {}
110 respsonse = self.testapp.post('/transients/1/akas',
111 params=params, status=404)
112 print(respsonse)
113 self.assertEqual(respsonse.status_code, 404)
115 def test_views_transients_element_akas_delete(self):
116 # PARAM DICTIONARY = URL TOKENS
117 params = {}
118 respsonse = self.testapp.delete('/transients/1/akas',
119 params=params, status=404)
120 print(respsonse)
121 self.assertEqual(respsonse.status_code, 404)
123 def test_views_transients_element_akas_put(self):
124 # PARAM DICTIONARY = URL TOKENS
125 params = {}
126 respsonse = self.testapp.put('/transients/1/akas',
127 params=params, status=404)
128 print(respsonse)
129 self.assertEqual(respsonse.status_code, 404)