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"
17exists = os.path.exists(settingsFile)
18if exists:
19 su = tools(
20 arguments={"settingsFile": settingsFile},
21 docString=__doc__,
22 logLevel="DEBUG",
23 options_first=False,
24 projectName=None,
25 defaultSettingsFile=False
26 )
27 arguments, settings, log, dbConn = su.setup()
29 # SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA
30 moduleDirectory = os.path.dirname(__file__)
31 pathToInputDir = moduleDirectory + "/input/"
32 pathToOutputDir = moduleDirectory + "/output/"
34 try:
35 shutil.rmtree(pathToOutputDir)
36 except:
37 pass
38 # COPY INPUT TO OUTPUT DIR
39 shutil.copytree(pathToInputDir, pathToOutputDir)
41 # Recursively create missing directories
42 if not os.path.exists(pathToOutputDir):
43 os.makedirs(pathToOutputDir)
45 # Recursively create missing directories
46 if not os.path.exists("/tmp/marshall_webapp/static/caches/stats/phaseIII"):
47 os.makedirs("/tmp/marshall_webapp/static/caches/stats/phaseIII")
49 # COMMON STATUS CODES
50 # 200 OK
51 # 301 Moved Permanently
52 # 302 Found - possibly rediected
53 # 304 Not Modified
54 # 400 Bad Request
55 # 403 Forbidden
56 # 409 Conflict
57 # 401 Unauthorized
58 # 404 Not Found
59 # 405 Method Not Allowed
60 # 408 Request Timeout
61 # 429 Too Many Requests
62 # 500 Internal Server Error
63 # 504 Gateway Timeout
64 # 502 Bad Gateway
67class test_views_resources_stats(BaseTest):
69 def __init__(self, *args, **kwargs):
70 BaseTest.__init__(self, *args, **kwargs)
72 self.testIni = moduleDirectory + "/../../../test.ini#marshall_webapp"
73 self.testSettings = settings
74 self.settings = settings
76 def test_01_views_resources_stats_post(self):
77 # PARAM DICTIONARY = URL TOKENS
78 params = {}
80 respsonse = self.testapp.post(
81 "/stats", params=params, status=404)
82 self.assertEqual(respsonse.status_code, 404)
84 def test_views_resources_stats_get(self):
85 # PARAM DICTIONARY = URL TOKENS
86 params = {}
88 # Recursively create missing directories
89 if not os.path.exists("/tmp/marshall_webapp/static/caches/stats/phaseIII"):
90 os.makedirs("/tmp/marshall_webapp/static/caches/stats/phaseIII")
92 params["format"] = "json"
93 respsonse = self.testapp.get('/stats',
94 params=params, status=404)
95 self.assertEqual(respsonse.status_code, 404)
96 params["format"] = "csv"
97 respsonse = self.testapp.get('/stats',
98 params=params, status=404)
99 self.assertEqual(respsonse.status_code, 404)
100 params["format"] = "plain_table"
101 respsonse = self.testapp.get('/stats',
102 params=params, status=404)
103 self.assertEqual(respsonse.status_code, 404)
104 params["format"] = None
105 respsonse = self.testapp.get('/stats',
106 params=params)
107 print(respsonse)
108 self.assertEqual(respsonse.status_code, 200)
110 def test_views_resources_stats_delete(self):
111 # PARAM DICTIONARY = URL TOKENS
112 params = {}
113 respsonse = self.testapp.delete('/stats',
114 params=params, status=404)
115 print(respsonse)
116 self.assertEqual(respsonse.status_code, 404)
118 def test_views_resources_stats_put(self):
119 # PARAM DICTIONARY = URL TOKENS
120 params = {}
121 respsonse = self.testapp.put('/stats',
122 params=params, status=404)
123 print(respsonse)
124 self.assertEqual(respsonse.status_code, 404)