Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rdos-python
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Julien David
rdos-python
Commits
d453f04f
Commit
d453f04f
authored
4 years ago
by
Ismail Moumni
Browse files
Options
Downloads
Patches
Plain Diff
Adding EXCEPTION
parent
9cd68b2c
No related branches found
No related tags found
1 merge request
!5
Wip adding tests and json functions
Pipeline
#663
passed with stage
in 13 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
client.py
+2
-6
2 additions, 6 deletions
client.py
tests/test_client.py
+3
-2
3 additions, 2 deletions
tests/test_client.py
tests/test_match_dict.py
+3
-3
3 additions, 3 deletions
tests/test_match_dict.py
tests/test_match_json.py
+8
-0
8 additions, 0 deletions
tests/test_match_json.py
with
16 additions
and
11 deletions
client.py
+
2
−
6
View file @
d453f04f
...
...
@@ -46,13 +46,13 @@ def run_client(Host, Port, message: str):
# Function returns a list containing missing values
def
match_dict
(
biblio
:
dict
,
gen
:
dict
):
missing
=
[]
if
(
len
(
biblio
)
!=
0
):
if
(
biblio
is
not
None
):
for
key
in
biblio
:
if
key
not
in
gen
:
missing
.
append
(
key
)
return
missing
else
:
raise
TypeError
(
"
Dictionnaire Vide!!
"
)
raise
Exception
(
"
Dictionnaire Vide!!
"
)
# Function send_st sends to socket data bytes
...
...
@@ -129,7 +129,3 @@ def help():
print
(
'
Generator parameters :
'
)
for
a
in
__RDOS_Gen__
:
print
(
"
Parameter: {}, Value : {}
"
.
format
(
a
,
__RDOS_Gen__
[
a
]))
if
__name__
==
'
__main__
'
:
print
(
match_query_dict
({
"
lala
"
:
"
MomO
"
},
{
"
lala
"
:
"
tata
"
}))
This diff is collapsed.
Click to expand it.
tests/test_client.py
+
3
−
2
View file @
d453f04f
import
pytest
import
requests
#
import requests
def
test_stupid
():
assert
True
!=
False
with
pytest
.
raises
(
Exception
):
assert
'
True
'
==
'
False
'
This diff is collapsed.
Click to expand it.
tests/test_match_dict.py
+
3
−
3
View file @
d453f04f
...
...
@@ -3,8 +3,8 @@
import
client
as
c
import
pytest
test_dict1
=
{
"
name
"
:
"
Michael
"
}
test_dict2
=
{
"
name
"
:
"
Michael
"
}
test_dict1
=
{
"
name
"
:
"
Michael
"
,
"
Rafael
"
:
"
Nadal
"
}
test_dict2
=
{
"
name
"
:
"
Michael
"
,
"
Rafael
"
:
""
}
def
test_match
():
...
...
@@ -14,4 +14,4 @@ def test_match():
def
test_bad_match_dict
():
with
pytest
.
raises
(
Exception
):
assert
c
.
match_dict
(
test_dict1
,
{}
)
assert
c
.
match_dict
(
{},
test_dict1
)
This diff is collapsed.
Click to expand it.
tests/test_match_json.py
+
8
−
0
View file @
d453f04f
...
...
@@ -4,8 +4,11 @@ import json
import
client
as
c
import
pytest
data
=
'
{
"
country
"
:
"
usa
"
,
"
people
"
:
""
}
'
bad_data
=
'
{
"
sasd
"
:
""
,
"
nam
"
: {
"
saasd
"
:
"
llam
"
} }
'
obj
=
json
.
loads
(
data
)
obj2
=
json
.
loads
(
bad_data
)
def
test_match_dict
():
...
...
@@ -13,6 +16,11 @@ def test_match_dict():
assert
var
==
[]
def
test_diff_match_dict
():
result
=
c
.
match_dict
(
obj
,
obj2
)
assert
result
is
not
None
def
test_bad_match_dict
():
with
pytest
.
raises
(
Exception
):
assert
c
.
match_dict
({},
obj
)
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