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
6296b974
Commit
6296b974
authored
8 years ago
by
Sebastian Lobinger
Browse files
Options
Downloads
Patches
Plain Diff
update test_sams_Hub.py to make a reflect the exampleApp szenario
#14
parent
a949d126
No related branches found
No related tags found
1 merge request
!8
Resolve "Ändern der Sprache in ExampleApp muss in beiden Sprachen funtkionieren"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_sams_hub.py
+49
-37
49 additions, 37 deletions
test/test_sams_hub.py
with
49 additions
and
37 deletions
test/test_sams_hub.py
+
49
−
37
View file @
6296b974
...
@@ -4,6 +4,7 @@ from sams_classes.exceptions import AppNotExist
...
@@ -4,6 +4,7 @@ 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
import
copy
def
eprint
(
*
args
,
**
kwargs
):
def
eprint
(
*
args
,
**
kwargs
):
print
(
*
args
,
file
=
sys
.
stderr
,
**
kwargs
)
print
(
*
args
,
file
=
sys
.
stderr
,
**
kwargs
)
...
@@ -223,34 +224,45 @@ class CaseMinimalSAMSHub(unittest.TestCase):
...
@@ -223,34 +224,45 @@ class CaseMinimalSAMSHub(unittest.TestCase):
def
test_hub_default_language_used
(
self
):
def
test_hub_default_language_used
(
self
):
"""
The hub default_language is prefered instead of app default_language
"""
"""
The hub default_language is prefered instead of app default_language
"""
wrong
=
'
Hello world!
'
langDicts
=
{
expected
=
'
Hallo Welt!
'
'
de
'
:
{
'
hello
'
:
'
Hallo Welt!
'
},
self
.
hub
.
addApp
(
'
en
'
:
{
'
hello
'
:
'
Hello world!
'
}
SAMSApp
(
}
name
=
'
test
'
for
langCode
,
langDict
in
langDicts
.
items
():
,
manifest
=
{
with
self
.
subTest
(
langCode
):
'
default_language
'
:
'
en
'
hub
=
SAMSHub
(
name
=
'
test
'
,
config
=
{
'
default_language
'
:
'
de
'
})
,
'
views
'
:[
hub
.
addApp
(
{
'
url
'
:
'
hello
'
SAMSApp
(
,
'
function
'
:
'
views.hello
'
}
name
=
'
test
'
]
,
manifest
=
{
}
'
default_language
'
:
langCode
,
langDict
=
{
,
'
views
'
:[
'
de
'
:
{
'
hello
'
:
expected
}
{
'
url
'
:
'
hello
'
,
'
en
'
:
{
'
hello
'
:
wrong
}
,
'
function
'
:
'
views.hello
'
}
}
]
)
}
)
,
langDict
=
copy
.
deepcopy
(
langDicts
)
self
.
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
)
client
=
self
.
hub
.
flaskApp
.
test_client
(
self
)
)
response
=
client
.
get
(
'
/test/hello
'
)
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
self
.
assertIs
(
response
.
status_code
,
200
)
with
hub
.
flaskApp
.
test_client
(
self
)
as
client
:
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
response
=
client
.
get
(
'
/test/hello
'
)
self
.
assertIs
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
langDict
[
'
hello
'
])
def
test_session_language_used
(
self
):
def
test_session_language_used
(
self
):
"""
use Session[
'
language
'
] if possible
"""
"""
use Session[
'
language
'
] if possible
"""
expected
=
'
Bonjour!
'
langDict
=
{
self
.
hub
.
addApp
(
'
de
'
:
{
'
hello
'
:
'
Hallo Welt!
'
},
'
en
'
:
{
'
hello
'
:
'
Hello world!
'
},
'
fr
'
:
{
'
hello
'
:
'
Bonjour tout le monde!
'
}
}
sessionLangs
=
[
'
de
'
,
'
en
'
,
'
fr
'
]
hub
=
SAMSHub
(
name
=
'
test
'
,
config
=
{
'
default_language
'
:
'
de
'
}
)
hub
.
addApp
(
SAMSApp
(
SAMSApp
(
name
=
'
test
'
name
=
'
test
'
,
manifest
=
{
,
manifest
=
{
...
@@ -260,19 +272,19 @@ class CaseMinimalSAMSHub(unittest.TestCase):
...
@@ -260,19 +272,19 @@ class CaseMinimalSAMSHub(unittest.TestCase):
,
'
function
'
:
'
views.hello
'
}
,
'
function
'
:
'
views.hello
'
}
]
]
}
}
,
langDict
=
{
,
langDict
=
copy
.
deepcopy
(
langDict
)
'
de
'
:
{
'
hello
'
:
'
falsch
'
}
,
'
en
'
:
{
'
hello
'
:
'
wrong
'
}
,
'
fr
'
:
{
'
hello
'
:
expected
}
}
)
)
)
)
self
.
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
for
sessionLang
in
sessionLangs
:
with
self
.
hub
.
flaskApp
.
test_client
(
self
)
as
client
:
eprint
(
langDict
)
with
client
.
session_transaction
()
as
session_simulation
:
with
self
.
subTest
(
sessionLang
):
session_simulation
[
'
language
'
]
=
'
fr
'
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
response
=
client
.
get
(
'
/test/hello
'
)
with
hub
.
flaskApp
.
test_client
(
self
)
as
client
:
self
.
assertIs
(
response
.
status_code
,
200
)
with
client
.
session_transaction
()
as
session_simulation
:
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
session_simulation
[
'
language
'
]
=
sessionLang
response
=
client
.
get
(
'
/test/hello
'
)
self
.
assertIs
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
langDict
[
sessionLang
][
'
hello
'
])
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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