Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sams-classes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
coding-at-fu
sams-classes
Commits
a518e7b3
Commit
a518e7b3
authored
8 years ago
by
slobinger
Browse files
Options
Downloads
Plain Diff
Merge branch '12-sams_hub_main_app_bugfix' into 'master'
update tes_main_app to test main apps with dots in its name
#12
Closes
#12
See merge request
!6
parents
97502a95
93b0e0b1
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_sams_hub.py
+66
-55
66 additions, 55 deletions
test/test_sams_hub.py
with
66 additions
and
55 deletions
test/test_sams_hub.py
+
66
−
55
View file @
a518e7b3
...
@@ -3,7 +3,7 @@ from sams_classes import SAMSHub, SAMSApp
...
@@ -3,7 +3,7 @@ from sams_classes import SAMSHub, SAMSApp
from
sams_classes.exceptions
import
AppNotExist
from
sams_classes.exceptions
import
AppNotExist
from
flask
import
Flask
,
Blueprint
from
flask
import
Flask
,
Blueprint
import
sys
,
time
import
sys
,
time
from
.
helper_classes
import
FlaskInThread
from
helper_classes
import
FlaskInThread
def
eprint
(
*
args
,
**
kwargs
):
def
eprint
(
*
args
,
**
kwargs
):
print
(
*
args
,
file
=
sys
.
stderr
,
**
kwargs
)
print
(
*
args
,
file
=
sys
.
stderr
,
**
kwargs
)
...
@@ -13,7 +13,7 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
...
@@ -13,7 +13,7 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
hub
=
SAMSHub
(
self
.
hub
=
SAMSHub
(
name
=
'
test
'
,
config
=
{
'
default_language
'
:
'
de
'
,
'
main_app
'
:
'
test
'
})
name
=
'
test
'
,
config
=
{
'
default_language
'
:
'
de
'
,
'
main_app
'
:
'
test
'
})
from
.
api_test_server
import
app
as
apiApp
from
api_test_server
import
app
as
apiApp
apiApp
.
config
[
'
TESTING
'
]
=
True
apiApp
.
config
[
'
TESTING
'
]
=
True
thApi
=
FlaskInThread
(
apiApp
,
host
=
"
localhost
"
,
port
=
4711
)
thApi
=
FlaskInThread
(
apiApp
,
host
=
"
localhost
"
,
port
=
4711
)
thApi
.
start
()
thApi
.
start
()
...
@@ -41,62 +41,71 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
...
@@ -41,62 +41,71 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
class
CaseSAMSHubWithMainApp
(
unittest
.
TestCase
):
class
CaseSAMSHubWithMainApp
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
hub
=
SAMSHub
(
name
=
'
test
'
,
config
=
{
'
default_language
'
:
'
de
'
,
'
main_app
'
:
'
test
'
})
def
test_main_app
(
self
):
def
test_main_app
(
self
):
"""
It is possible to declare a main app where the urls have no prefix
"""
"""
It is possible to declare a main app where the urls have no prefix
"""
appname
=
'
test.app
'
szenarios
=
[
expected_names
=
[
{
'
main_app
'
:
'
test
'
,
'
extra_app
'
:
'
test.app
'
},
'
Hauptanwendung Punkt 1
'
,
'
Hauptanwendung Punkt 2
'
,
'
Zusatzanwendung 1
'
{
'
main_app
'
:
'
test.app
'
,
'
extra_app
'
:
'
test
'
}
]
]
urls
=
[
''
,
'
2
'
,
'
app/1
'
]
for
szenario
in
szenarios
:
name_vars
=
[
'
main_1
'
,
'
main_2
'
,
'
app_1
'
]
main_app
=
szenario
[
'
main_app
'
]
expected
=
''
.
join
((
extra_app
=
szenario
[
'
extra_app
'
]
"
<ul>
\n\n
<li><a href=
'
/
"
,
urls
[
0
],
"'
>
"
,
expected_names
[
0
],
with
self
.
subTest
(
main_app
=
main_app
,
extra_app
=
extra_app
):
"
</a>
\n\n
<ul>
\n\n
<li><a href=
'
/
"
,
urls
[
1
],
"'
>
"
,
expected_names
[
1
],
hub
=
SAMSHub
(
"
</a>
\n\n
</li>
\n\n
</ul>
\n\n
</li>
\n\n
<li><a href=
'
/
"
,
appname
,
'
/
'
,
urls
[
2
],
"'
>
"
,
name
=
'
test
'
,
expected_names
[
2
],
'
</a>
\n\n
</li>
\n\n
</ul>
'
config
=
{
'
default_language
'
:
'
de
'
,
'
main_app
'
:
main_app
}
))
)
self
.
hub
.
addApp
(
expected_names
=
[
SAMSApp
(
'
Hauptanwendung Punkt 1
'
,
'
Hauptanwendung Punkt 2
'
,
name
=
'
test
'
,
'
Zusatzanwendung 1
'
manifest
=
{
]
'
default_language
'
:
'
de
'
,
urls
=
[
''
,
'
2
'
,
'
app/1
'
]
'
views
'
:[
name_vars
=
[
'
main_1
'
,
'
main_2
'
,
'
app_1
'
]
{
'
url
'
:
urls
[
0
],
'
function
'
:
'
views.menu_test
'
},
expected
=
''
.
join
((
{
'
url
'
:
urls
[
1
],
'
function
'
:
'
views.do_nothing
'
}
"
<ul>
\n\n
<li><a href=
'
/
"
,
urls
[
0
],
"'
>
"
,
expected_names
[
0
],
],
"
</a>
\n\n
<ul>
\n\n
<li><a href=
'
/
"
,
urls
[
1
],
"'
>
"
,
expected_names
[
1
],
'
menu
'
:[
"
</a>
\n\n
</li>
\n\n
</ul>
\n\n
</li>
\n\n
<li><a href=
'
/
"
,
extra_app
,
'
/
'
,
{
urls
[
2
],
"'
>
"
,
'
url
'
:
urls
[
0
],
'
name_string
'
:
name_vars
[
0
],
expected_names
[
2
],
'
</a>
\n\n
</li>
\n\n
</ul>
'
'
menu
'
:
[{
'
url
'
:
urls
[
1
],
'
name_string
'
:
name_vars
[
1
]}]
))
hub
.
addApp
(
SAMSApp
(
name
=
main_app
,
manifest
=
{
'
default_language
'
:
'
de
'
,
'
views
'
:[
{
'
url
'
:
urls
[
0
],
'
function
'
:
'
views.menu_test
'
},
{
'
url
'
:
urls
[
1
],
'
function
'
:
'
views.do_nothing
'
}
],
'
menu
'
:[
{
'
url
'
:
urls
[
0
],
'
name_string
'
:
name_vars
[
0
],
'
menu
'
:
[{
'
url
'
:
urls
[
1
],
'
name_string
'
:
name_vars
[
1
]}]
}
]
}
}
]
,
langDict
=
{
'
de
'
:
dict
(
zip
(
name_vars
,
expected_names
))}
}
)
,
langDict
=
{
'
de
'
:
dict
(
zip
(
name_vars
,
expected_names
))}
)
)
hub
.
addApp
(
)
SAMSApp
(
self
.
hub
.
addApp
(
name
=
extra_app
,
SAMSApp
(
manifest
=
{
name
=
appname
,
'
default_language
'
:
'
de
'
,
manifest
=
{
'
views
'
:
[{
'
url
'
:
urls
[
2
],
'
function
'
:
'
views.do_nothing
'
}],
'
default_language
'
:
'
de
'
,
'
menu
'
:
[{
'
url
'
:
urls
[
2
],
'
name_string
'
:
name_vars
[
2
]}]
'
views
'
:
[{
'
url
'
:
urls
[
2
],
'
function
'
:
'
views.do_nothing
'
}],
},
langDict
=
{
'
de
'
:
dict
(
zip
(
name_vars
,
expected_names
))}
'
menu
'
:
[{
'
url
'
:
urls
[
2
],
'
name_string
'
:
name_vars
[
2
]}]
)
},
langDict
=
{
'
de
'
:
dict
(
zip
(
name_vars
,
expected_names
))}
)
)
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
)
with
hub
.
flaskApp
.
test_client
(
self
)
as
client
:
self
.
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
response
=
client
.
get
(
'
/
'
)
with
self
.
hub
.
flaskApp
.
test_client
(
self
)
as
client
:
self
.
assertIs
(
response
.
status_code
,
200
)
response
=
client
.
get
(
'
/
'
)
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
self
.
assertIs
(
response
.
status_code
,
200
)
response
=
client
.
get
(
'
/
'
+
urls
[
1
])
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
self
.
assertIs
(
response
.
status_code
,
200
)
response
=
client
.
get
(
'
/
'
+
urls
[
1
])
response
=
client
.
get
(
'
/
'
+
extra_app
+
'
/
'
+
urls
[
2
])
self
.
assertIs
(
response
.
status_code
,
200
)
self
.
assertIs
(
response
.
status_code
,
200
)
response
=
client
.
get
(
'
/
'
+
appname
+
'
/
'
+
urls
[
2
])
self
.
assertIs
(
response
.
status_code
,
200
)
class
CaseSAMSHubInitExceptions
(
unittest
.
TestCase
):
class
CaseSAMSHubInitExceptions
(
unittest
.
TestCase
):
...
@@ -264,4 +273,6 @@ class CaseMinimalSAMSHub(unittest.TestCase):
...
@@ -264,4 +273,6 @@ class CaseMinimalSAMSHub(unittest.TestCase):
session_simulation
[
'
language
'
]
=
'
fr
'
session_simulation
[
'
language
'
]
=
'
fr
'
response
=
client
.
get
(
'
/test/hello
'
)
response
=
client
.
get
(
'
/test/hello
'
)
self
.
assertIs
(
response
.
status_code
,
200
)
self
.
assertIs
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
\ No newline at end of file
if
__name__
==
'
__main__
'
:
unittest
.
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment