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 # COMMON STATUS CODES
46 # 200 OK
47 # 301 Moved Permanently
48 # 302 Found - possibly rediected
49 # 304 Not Modified
50 # 400 Bad Request
51 # 403 Forbidden
52 # 409 Conflict
53 # 401 Unauthorized
54 # 404 Not Found
55 # 405 Method Not Allowed
56 # 408 Request Timeout
57 # 429 Too Many Requests
58 # 500 Internal Server Error
59 # 504 Gateway Timeout
60 # 502 Bad Gateway
63class test_views_resources_members(BaseTest):
65 def __init__(self, *args, **kwargs):
66 BaseTest.__init__(self, *args, **kwargs)
68 self.testIni = moduleDirectory + "/../../../test.ini#marshall_webapp"
69 self.testSettings = settings
70 self.settings = settings
72 def test_views_resources_members_post(self):
73 # PARAM DICTIONARY = URL TOKENS
74 params = {}
76 respsonse = self.testapp.post(
77 "/members", params=params, status=404)
78 self.assertEqual(respsonse.status_code, 404)
80 def test_views_resources_members_get(self):
81 # PARAM DICTIONARY = URL TOKENS
82 params = {}
84 params["format"] = "html"
85 respsonse = self.testapp.get('/members',
86 params=params)
87 print(respsonse)
88 self.assertEqual(respsonse.status_code, 200)
89 params["format"] = "json"
90 respsonse = self.testapp.get('/members',
91 params=params)
92 print(respsonse)
93 self.assertEqual(respsonse.status_code, 200)
94 params["format"] = "csv"
95 respsonse = self.testapp.get('/members',
96 params=params)
97 print(respsonse)
98 self.assertEqual(respsonse.status_code, 200)
99 params["format"] = "plain_table"
100 respsonse = self.testapp.get('/members',
101 params=params)
102 print(respsonse)
103 self.assertEqual(respsonse.status_code, 200)
104 params["format"] = None
105 respsonse = self.testapp.get('/members',
106 params=params)
107 print(respsonse)
108 self.assertEqual(respsonse.status_code, 200)
110 def test_views_resources_members_delete(self):
111 # PARAM DICTIONARY = URL TOKENS
112 params = {}
113 respsonse = self.testapp.delete('/members',
114 params=params, status=404)
115 print(respsonse)
116 self.assertEqual(respsonse.status_code, 404)
118 def test_views_resources_members_put(self):
119 # PARAM DICTIONARY = URL TOKENS
120 params = {}
121 respsonse = self.testapp.put('/members',
122 params=params, status=404)
123 print(respsonse)
124 self.assertEqual(respsonse.status_code, 404)