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)
46class test_views_resources_transients_element(BaseTest):
48 def __init__(self, *args, **kwargs):
49 BaseTest.__init__(self, *args, **kwargs)
51 # xt-setup-unit-testing-files-and-folders
53 self.testIni = moduleDirectory + "/../../../test.ini#marshall_webapp"
55 self.testSettings = settings
56 self.settings = settings
58 def test_views_reosurces_transients_element_get(self):
59 # PARAM DICTIONARY = URL TOKENS
60 params = {}
61 respsonse = self.testapp.get('/transients/1',
62 params=params)
63 self.assertEqual(respsonse.status_code, 200)
65 def test_views_reosurces_transients_element_post(self):
66 # PARAM DICTIONARY = URL TOKENS
67 params = {}
68 respsonse = self.testapp.post('/transients/1',
69 params=params)
70 self.assertEqual(respsonse.status_code, 200)
72 def test_views_reosurces_transients_element_delete(self):
73 # PARAM DICTIONARY = URL TOKENS
74 params = {}
75 respsonse = self.testapp.delete('/transients/1',
76 params=params, status=404)
77 self.assertEqual(respsonse.status_code, 404)
79 def test_views_reosurces_transients_element_put(self):
80 # PARAM DICTIONARY = URL TOKENS
81 params = {}
82 respsonse = self.testapp.put('/transients/1',
83 params=params)
84 self.assertEqual(respsonse.status_code, 200)
86 def test_02_views_reosurces_transients_element_put_move(self):
88 params = {
89 "method": "put",
90 "mwl": "inbox",
91 }
92 respsonse = self.testapp.put('/transients/1',
93 params=params)
94 self.assertEqual(respsonse.status_code, 200)
96 def test_views_reosurces_transients_element_put_priority(self):
98 params = {
99 "observationPriority": "3",
100 "method": "put",
101 }
102 respsonse = self.testapp.put('/transients/1',
103 params=params)
104 self.assertEqual(respsonse.status_code, 200)
106 def test_views_reosurces_transients_element_put_pi(self):
108 params = {
109 "method": "put",
110 "piName": "boblin",
111 "piEmail": "d.r.young@qub.ac.uk",
112 "redirectURL": "/marshall/transients/1",
113 }
114 respsonse = self.testapp.put('/transients/1',
115 params=params)
116 self.assertEqual(respsonse.status_code, 302)
118 def test_views_reosurces_transients_element_post_classification(self):
120 params = {
121 "clsSource": "atel",
122 "clsObsdate": "2022-08-12",
123 "clsType": "supernova",
124 "clsSnClassification": "Ib",
125 "clsRedshift": "3.4",
126 "clsSendTo": "no",
127 "clsClassificationWRTMax": "at+max",
128 "redirectURL": "/marshall/transients/1",
129 }
130 respsonse = self.testapp.post('/transients/1',
131 params=params)
132 # print(respsonse)
133 self.assertEqual(respsonse.status_code, 302)
135 # x-print-testpage-for-pessto-marshall-web-object
137 # x-class-to-test-named-worker-function