Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ophélie Gagnard
slapos.core
Commits
7ecd6bc3
Commit
7ecd6bc3
authored
Nov 22, 2019
by
Jérome Perrin
Committed by
Thomas Gambier
Nov 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_slapproxy: test loadComputerConfigurationFromXML keeps partitions
parent
15d6f6cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
6 deletions
+58
-6
slapos/tests/test_slapproxy.py
slapos/tests/test_slapproxy.py
+58
-6
No files found.
slapos/tests/test_slapproxy.py
View file @
7ecd6bc3
...
@@ -163,8 +163,9 @@ database_uri = %(tempdir)s/lib/proxy.db
...
@@ -163,8 +163,9 @@ database_uri = %(tempdir)s/lib/proxy.db
class
TestLoadComputerConfiguration
(
BasicMixin
,
unittest
.
TestCase
):
class
TestLoadComputerConfiguration
(
BasicMixin
,
unittest
.
TestCase
):
"""tests /loadComputerConfigurationFromXML the endpoint for format
"""tests /loadComputerConfigurationFromXML the endpoint for format
"""
"""
def
test_loadComputerConfigurationFromXML_remove_partitions
(
self
):
def
setUp
(
self
):
computer_dict
=
{
super
(
TestLoadComputerConfiguration
,
self
).
setUp
()
self
.
computer_dict
=
{
'reference'
:
self
.
computer_id
,
'reference'
:
self
.
computer_id
,
'address'
:
'12.34.56.78'
,
'address'
:
'12.34.56.78'
,
'netmask'
:
'255.255.255.255'
,
'netmask'
:
'255.255.255.255'
,
...
@@ -178,20 +179,71 @@ class TestLoadComputerConfiguration(BasicMixin, unittest.TestCase):
...
@@ -178,20 +179,71 @@ class TestLoadComputerConfiguration(BasicMixin, unittest.TestCase):
},
},
],
],
'tap'
:
{
'name'
:
'tap0'
},
'tap'
:
{
'name'
:
'tap0'
},
},
{
'reference'
:
'slappart2'
,
'address_list'
:
[
{
'addr'
:
'5.6.7.8'
,
'netmask'
:
'255.255.255.255'
},
],
'tap'
:
{
'name'
:
'tap1'
},
}
}
],
],
}
}
def
test_loadComputerConfigurationFromXML_keep_partitions
(
self
):
rv
=
self
.
app
.
post
(
'/loadComputerConfigurationFromXML'
,
data
=
{
rv
=
self
.
app
.
post
(
'/loadComputerConfigurationFromXML'
,
data
=
{
'computer_id'
:
self
.
computer_id
,
'computer_id'
:
self
.
computer_id
,
'xml'
:
dumps
(
computer_dict
),
'xml'
:
dumps
(
self
.
computer_dict
),
})
})
self
.
assertEqual
(
rv
.
_status_code
,
200
)
self
.
assertEqual
(
rv
.
_status_code
,
200
)
# call again with different partition reference, old partition will be removed
self
.
app
.
post
(
'/requestComputerPartition'
,
data
=
{
'computer_id'
:
self
.
computer_id
,
'software_release'
:
'https://example.com/software.cfg'
,
'software_type'
:
'default'
,
'computer_partition_id'
:
'slappart1'
,
'state'
:
dumps
(
'started'
),
'partition_parameter_xml'
:
dumps
({
'foo'
:
'bar'
}),
'filter_xml'
:
dumps
({}),
'shared_xml'
:
dumps
({})
})
computer
=
loads
(
self
.
app
.
get
(
'/getFullComputerInformation'
,
query_string
=
{
'computer_id'
:
self
.
computer_id
}).
data
)
self
.
assertEqual
(
[
'https://example.com/software.cfg'
],
[
p
.
getSoftwareRelease
().
getURI
()
for
p
in
computer
.
_computer_partition_list
if
p
.
getId
()
==
'slappart1'
])
# load configuration from XML again
rv
=
self
.
app
.
post
(
'/loadComputerConfigurationFromXML'
,
data
=
{
'computer_id'
:
self
.
computer_id
,
'xml'
:
dumps
(
self
.
computer_dict
),
})
self
.
assertEqual
(
rv
.
_status_code
,
200
)
# partition is kept
computer
=
loads
(
self
.
app
.
get
(
'/getFullComputerInformation'
,
query_string
=
{
'computer_id'
:
self
.
computer_id
}).
data
)
self
.
assertEqual
(
[
'https://example.com/software.cfg'
],
[
p
.
getSoftwareRelease
().
getURI
()
for
p
in
computer
.
_computer_partition_list
if
p
.
getId
()
==
'slappart1'
])
def
test_loadComputerConfigurationFromXML_remove_partitions
(
self
):
rv
=
self
.
app
.
post
(
'/loadComputerConfigurationFromXML'
,
data
=
{
'computer_id'
:
self
.
computer_id
,
'xml'
:
dumps
(
self
.
computer_dict
),
})
self
.
assertEqual
(
rv
.
_status_code
,
200
)
# call again with one less partition reference, old partition will be removed
# and a new partition will be used.
# and a new partition will be used.
computer_dict
[
'partition_list'
][
0
][
'reference'
]
=
'something else'
self
.
computer_dict
[
'partition_list'
]
=
[
self
.
computer_dict
[
'partition_list'
][
0
]]
self
.
computer_dict
[
'partition_list'
][
0
][
'reference'
]
=
'something else'
rv
=
self
.
app
.
post
(
'/loadComputerConfigurationFromXML'
,
data
=
{
rv
=
self
.
app
.
post
(
'/loadComputerConfigurationFromXML'
,
data
=
{
'computer_id'
:
self
.
computer_id
,
'computer_id'
:
self
.
computer_id
,
'xml'
:
dumps
(
computer_dict
),
'xml'
:
dumps
(
self
.
computer_dict
),
})
})
self
.
assertEqual
(
rv
.
_status_code
,
200
)
self
.
assertEqual
(
rv
.
_status_code
,
200
)
computer
=
loads
(
computer
=
loads
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment