From 2ce09c96bd925c4461c7caa4aa32162a34f5a8b8 Mon Sep 17 00:00:00 2001 From: tivaliy Date: Tue, 31 May 2016 11:51:00 +0300 Subject: [PATCH] Align file path for 'fuel2 network-template upload' Remove extra '.yaml' extension from filename that erroneously added while executing fuel2 network-template upload command, e.g.: fuel2 network-template upload -f network_template_1.yaml 1 Change-Id: I0ffdcec36dbca6b105c36f9b841627f479cbee65 Closes-Bug: 1587302 --- fuelclient/objects/environment.py | 6 +++--- fuelclient/tests/unit/v2/lib/test_network_template.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fuelclient/objects/environment.py b/fuelclient/objects/environment.py index 77f9b55..a00c426 100644 --- a/fuelclient/objects/environment.py +++ b/fuelclient/objects/environment.py @@ -202,14 +202,14 @@ class Environment(BaseObject): self._check_dir(directory) network_template_file_path = self.get_network_template_data_path( directory) - return self.read_network_template_data_from_file( - network_template_file_path, serializer) + return (serializer or self.serializer).\ + read_from_file(network_template_file_path) def read_network_template_data_from_file(self, file_path=None, serializer=None): """Used by 'fuel2' command line utility.""" return (serializer or self.serializer).\ - read_from_file(file_path) + read_from_full_path(file_path) @property def status(self): diff --git a/fuelclient/tests/unit/v2/lib/test_network_template.py b/fuelclient/tests/unit/v2/lib/test_network_template.py index 74eb2a2..1acf44d 100644 --- a/fuelclient/tests/unit/v2/lib/test_network_template.py +++ b/fuelclient/tests/unit/v2/lib/test_network_template.py @@ -46,8 +46,12 @@ class TestNetworkTemplateFacade(test_api.BaseLibTest): m_open = mock.mock_open(read_data=common_net_template.YAML_TEMPLATE) with mock.patch('fuelclient.cli.serializers.open', m_open, create=True): - self.client.upload_network_template(self.env_id) + self.client.upload_network_template( + self.env_id, + 'fake_network_template_1.yaml' + ) + m_open.assert_called_with('fake_network_template_1.yaml', 'r') self.assertTrue(matcher.called) self.assertEqual(expected_body, matcher.last_request.json())