Switch TestCase attribute criteria to result
[functest.git] / functest / tests / unit / utils / test_functest_utils.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2016 Orange and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 import logging
11 import os
12 import time
13 import unittest
14 import urllib2
15
16 from git.exc import NoSuchPathError
17 import mock
18 import requests
19
20 from functest.tests.unit import test_utils
21 from functest.utils import functest_utils
22
23
24 class FunctestUtilsTesting(unittest.TestCase):
25
26     logging.disable(logging.CRITICAL)
27
28     def setUp(self):
29         self.url = 'http://www.opnfv.org/'
30         self.timeout = 5
31         self.dest_path = 'test_path'
32         self.repo_path = 'test_repo_path'
33         self.installer = 'test_installer'
34         self.scenario = 'test_scenario'
35         self.build_tag = 'jenkins-functest-fuel-opnfv-jump-2-daily-master-190'
36         self.build_tag_week = 'jenkins-functest-fuel-baremetal-weekly-master-8'
37         self.version = 'master'
38         self.node_name = 'test_node_name'
39         self.project = 'test_project'
40         self.case_name = 'test_case_name'
41         self.status = 'test_status'
42         self.details = 'test_details'
43         self.db_url = 'test_db_url'
44         self.success_rate = 2.0
45         self.criteria = 'test_criteria==2.0'
46         self.result = 'PASS'
47         self.start_date = 1482624000
48         self.stop_date = 1482624000
49         self.start_time = time.time()
50         self.stop_time = time.time()
51         self.readline = -1
52         self.test_ip = ['10.1.23.4', '10.1.14.15', '10.1.16.15']
53         self.test_file = 'test_file'
54         self.error_msg = 'test_error_msg'
55         self.cmd = 'test_cmd'
56         self.output_file = 'test_output_file'
57         self.testname = 'testname'
58         self.testcase_dict = {'case_name': 'testname',
59                               'criteria': self.criteria}
60         self.parameter = 'general.openstack.image_name'
61         self.config_yaml = 'test_config_yaml-'
62         self.db_url_env = 'http://foo/testdb'
63         self.file_yaml = {'general': {'openstack': {'image_name':
64                                                     'test_image_name'}}}
65
66     @mock.patch('urllib2.urlopen',
67                 side_effect=urllib2.URLError('no host given'))
68     def test_check_internet_connectivity_failed(self, mock_method):
69         self.assertFalse(functest_utils.check_internet_connectivity())
70         mock_method.assert_called_once_with(self.url, timeout=self.timeout)
71
72     @mock.patch('urllib2.urlopen')
73     def test_check_internet_connectivity_default(self, mock_method):
74         self.assertTrue(functest_utils.check_internet_connectivity())
75         mock_method.assert_called_once_with(self.url, timeout=self.timeout)
76
77     @mock.patch('urllib2.urlopen')
78     def test_check_internet_connectivity_debian(self, mock_method):
79         self.url = "https://www.debian.org/"
80         self.assertTrue(functest_utils.check_internet_connectivity(self.url))
81         mock_method.assert_called_once_with(self.url, timeout=self.timeout)
82
83     @mock.patch('urllib2.urlopen',
84                 side_effect=urllib2.URLError('no host given'))
85     def test_download_url_failed(self, mock_url):
86         self.assertFalse(functest_utils.download_url(self.url, self.dest_path))
87
88     @mock.patch('urllib2.urlopen')
89     def test_download_url_default(self, mock_url):
90         with mock.patch("__builtin__.open", mock.mock_open()) as m, \
91                 mock.patch('functest.utils.functest_utils.shutil.copyfileobj')\
92                 as mock_sh:
93             name = self.url.rsplit('/')[-1]
94             dest = self.dest_path + "/" + name
95             self.assertTrue(functest_utils.download_url(self.url,
96                                                         self.dest_path))
97             m.assert_called_once_with(dest, 'wb')
98             self.assertTrue(mock_sh.called)
99
100     def test_get_git_branch(self):
101         with mock.patch('functest.utils.functest_utils.Repo') as mock_repo:
102             mock_obj2 = mock.Mock()
103             attrs = {'name': 'test_branch'}
104             mock_obj2.configure_mock(**attrs)
105
106             mock_obj = mock.Mock()
107             attrs = {'active_branch': mock_obj2}
108             mock_obj.configure_mock(**attrs)
109
110             mock_repo.return_value = mock_obj
111             self.assertEqual(functest_utils.get_git_branch(self.repo_path),
112                              'test_branch')
113
114     @mock.patch('functest.utils.functest_utils.Repo',
115                 side_effect=NoSuchPathError)
116     def test_get_git_branch_failed(self, mock_repo):
117         self.assertRaises(NoSuchPathError,
118                           lambda: functest_utils.get_git_branch(self.repo_path
119                                                                 ))
120
121     @mock.patch('functest.utils.functest_utils.logger.error')
122     def test_get_installer_type_failed(self, mock_logger_error):
123         with mock.patch.dict(os.environ,
124                              {},
125                              clear=True):
126             self.assertEqual(functest_utils.get_installer_type(),
127                              "Unknown_installer")
128             mock_logger_error.assert_called_once_with("Impossible to retrieve"
129                                                       " the installer type")
130
131     def test_get_installer_type_default(self):
132         with mock.patch.dict(os.environ,
133                              {'INSTALLER_TYPE': 'test_installer'},
134                              clear=True):
135             self.assertEqual(functest_utils.get_installer_type(),
136                              self.installer)
137
138     @mock.patch('functest.utils.functest_utils.logger.info')
139     def test_get_scenario_failed(self, mock_logger_info):
140         with mock.patch.dict(os.environ,
141                              {},
142                              clear=True):
143             self.assertEqual(functest_utils.get_scenario(),
144                              "os-nosdn-nofeature-noha")
145             mock_logger_info.assert_called_once_with("Impossible to retrieve "
146                                                      "the scenario.Use "
147                                                      "default "
148                                                      "os-nosdn-nofeature-noha")
149
150     def test_get_scenario_default(self):
151         with mock.patch.dict(os.environ,
152                              {'DEPLOY_SCENARIO': 'test_scenario'},
153                              clear=True):
154             self.assertEqual(functest_utils.get_scenario(),
155                              self.scenario)
156
157     @mock.patch('functest.utils.functest_utils.get_build_tag')
158     def test_get_version_daily_job(self, mock_get_build_tag):
159         mock_get_build_tag.return_value = self.build_tag
160         self.assertEqual(functest_utils.get_version(), self.version)
161
162     @mock.patch('functest.utils.functest_utils.get_build_tag')
163     def test_get_version_weekly_job(self, mock_get_build_tag):
164         mock_get_build_tag.return_value = self.build_tag_week
165         self.assertEqual(functest_utils.get_version(), self.version)
166
167     @mock.patch('functest.utils.functest_utils.get_build_tag')
168     def test_get_version_with_dummy_build_tag(self, mock_get_build_tag):
169         mock_get_build_tag.return_value = 'whatever'
170         self.assertEqual(functest_utils.get_version(), 'unknown')
171
172     @mock.patch('functest.utils.functest_utils.get_build_tag')
173     def test_get_version_unknown(self, mock_get_build_tag):
174         mock_get_build_tag.return_value = "unknown_build_tag"
175         self.assertEqual(functest_utils.get_version(), "unknown")
176
177     @mock.patch('functest.utils.functest_utils.logger.info')
178     def test_get_pod_name_failed(self, mock_logger_info):
179         with mock.patch.dict(os.environ,
180                              {},
181                              clear=True):
182             self.assertEqual(functest_utils.get_pod_name(),
183                              "unknown-pod")
184             mock_logger_info.assert_called_once_with("Unable to retrieve "
185                                                      "the POD name from "
186                                                      "environment. Using "
187                                                      "pod name 'unknown-pod'")
188
189     def test_get_pod_name_default(self):
190         with mock.patch.dict(os.environ,
191                              {'NODE_NAME': 'test_node_name'},
192                              clear=True):
193             self.assertEqual(functest_utils.get_pod_name(),
194                              self.node_name)
195
196     @mock.patch('functest.utils.functest_utils.logger.info')
197     def test_get_build_tag_failed(self, mock_logger_info):
198         with mock.patch.dict(os.environ,
199                              {},
200                              clear=True):
201             self.assertEqual(functest_utils.get_build_tag(),
202                              "none")
203             mock_logger_info.assert_called_once_with("Impossible to retrieve"
204                                                      " the build tag")
205
206     def test_get_build_tag_default(self):
207         with mock.patch.dict(os.environ,
208                              {'BUILD_TAG': self.build_tag},
209                              clear=True):
210             self.assertEqual(functest_utils.get_build_tag(),
211                              self.build_tag)
212
213     def test_get_db_url_env_var(self):
214         with mock.patch.dict(os.environ,
215                              {'TEST_DB_URL': self.db_url_env,
216                               'CONFIG_FUNCTEST_YAML':
217                               "./functest/ci/config_functest.yaml"},
218                              clear=True):
219             self.assertEqual(functest_utils.get_db_url(),
220                              self.db_url_env)
221
222     @mock.patch('functest.utils.functest_utils.get_functest_config')
223     def test_get_db_url_default(self, mock_get_functest_config):
224         mock_get_functest_config.return_value = self.db_url
225         self.assertEqual(functest_utils.get_db_url(), self.db_url)
226         mock_get_functest_config.assert_called_once_with('results.test_db_url')
227
228     @mock.patch('functest.utils.functest_utils.logger.info')
229     def test_logger_test_results(self, mock_logger_info):
230         with mock.patch('functest.utils.functest_utils.get_pod_name',
231                         return_value=self.node_name), \
232                 mock.patch('functest.utils.functest_utils.get_scenario',
233                            return_value=self.scenario), \
234                 mock.patch('functest.utils.functest_utils.get_version',
235                            return_value=self.version), \
236                 mock.patch('functest.utils.functest_utils.get_build_tag',
237                            return_value=self.build_tag), \
238                 mock.patch('functest.utils.functest_utils.get_db_url',
239                            return_value=self.db_url):
240             functest_utils.logger_test_results(self.project, self.case_name,
241                                                self.status, self.details)
242             mock_logger_info.assert_called_once_with(
243                 "\n"
244                 "****************************************\n"
245                 "\t %(p)s/%(n)s results \n\n"
246                 "****************************************\n"
247                 "DB:\t%(db)s\n"
248                 "pod:\t%(pod)s\n"
249                 "version:\t%(v)s\n"
250                 "scenario:\t%(s)s\n"
251                 "status:\t%(c)s\n"
252                 "build tag:\t%(b)s\n"
253                 "details:\t%(d)s\n"
254                 % {'p': self.project,
255                     'n': self.case_name,
256                     'db': self.db_url,
257                     'pod': self.node_name,
258                     'v': self.version,
259                     's': self.scenario,
260                     'c': self.status,
261                     'b': self.build_tag,
262                     'd': self.details})
263
264     def _get_env_dict(self, var):
265         dic = {'INSTALLER_TYPE': self.installer,
266                'DEPLOY_SCENARIO': self.scenario,
267                'NODE_NAME': self.node_name,
268                'BUILD_TAG': self.build_tag}
269         dic.pop(var, None)
270         return dic
271
272     def _test_push_results_to_db_missing_env(self, env_var):
273         dic = self._get_env_dict(env_var)
274         with mock.patch('functest.utils.functest_utils.get_db_url',
275                         return_value=self.db_url), \
276                 mock.patch.dict(os.environ,
277                                 dic,
278                                 clear=True), \
279                 mock.patch('functest.utils.functest_utils.logger.error') \
280                 as mock_logger_error:
281             functest_utils.push_results_to_db(self.project, self.case_name,
282                                               self.start_date, self.stop_date,
283                                               self.result, self.details)
284             mock_logger_error.assert_called_once_with("Please set env var: " +
285                                                       str("\'" + env_var +
286                                                           "\'"))
287
288     def test_push_results_to_db_missing_installer(self):
289         self._test_push_results_to_db_missing_env('INSTALLER_TYPE')
290
291     def test_push_results_to_db_missing_scenario(self):
292         self._test_push_results_to_db_missing_env('DEPLOY_SCENARIO')
293
294     def test_push_results_to_db_missing_nodename(self):
295         self._test_push_results_to_db_missing_env('NODE_NAME')
296
297     def test_push_results_to_db_missing_buildtag(self):
298         self._test_push_results_to_db_missing_env('BUILD_TAG')
299
300     def test_push_results_to_db_request_post_failed(self):
301         dic = self._get_env_dict(None)
302         with mock.patch('functest.utils.functest_utils.get_db_url',
303                         return_value=self.db_url), \
304                 mock.patch.dict(os.environ,
305                                 dic,
306                                 clear=True), \
307                 mock.patch('functest.utils.functest_utils.logger.error') \
308                 as mock_logger_error, \
309                 mock.patch('functest.utils.functest_utils.requests.post',
310                            side_effect=requests.RequestException):
311             self.assertFalse(functest_utils.
312                              push_results_to_db(self.project, self.case_name,
313                                                 self.start_date,
314                                                 self.stop_date,
315                                                 self.result, self.details))
316             mock_logger_error.assert_called_once_with(test_utils.
317                                                       RegexMatch("Pushing "
318                                                                  "Result to"
319                                                                  " DB"
320                                                                  "(\S+\s*) "
321                                                                  "failed:"))
322
323     def test_push_results_to_db_request_post_exception(self):
324         dic = self._get_env_dict(None)
325         with mock.patch('functest.utils.functest_utils.get_db_url',
326                         return_value=self.db_url), \
327                 mock.patch.dict(os.environ,
328                                 dic,
329                                 clear=True), \
330                 mock.patch('functest.utils.functest_utils.logger.error') \
331                 as mock_logger_error, \
332                 mock.patch('functest.utils.functest_utils.requests.post',
333                            side_effect=Exception):
334             self.assertFalse(functest_utils.
335                              push_results_to_db(self.project, self.case_name,
336                                                 self.start_date,
337                                                 self.stop_date,
338                                                 self.result, self.details))
339             self.assertTrue(mock_logger_error.called)
340
341     def test_push_results_to_db_default(self):
342         dic = self._get_env_dict(None)
343         with mock.patch('functest.utils.functest_utils.get_db_url',
344                         return_value=self.db_url), \
345                 mock.patch.dict(os.environ,
346                                 dic,
347                                 clear=True), \
348                 mock.patch('functest.utils.functest_utils.requests.post'):
349             self.assertTrue(functest_utils.
350                             push_results_to_db(self.project, self.case_name,
351                                                self.start_date,
352                                                self.stop_date,
353                                                self.result, self.details))
354     readline = 0
355     test_ip = ['10.1.23.4', '10.1.14.15', '10.1.16.15']
356
357     @staticmethod
358     def readline_side():
359         if FunctestUtilsTesting.readline == \
360                 len(FunctestUtilsTesting.test_ip) - 1:
361             return False
362         FunctestUtilsTesting.readline += 1
363         return FunctestUtilsTesting.test_ip[FunctestUtilsTesting.readline]
364
365     # TODO: get_resolvconf_ns
366     @mock.patch('functest.utils.functest_utils.dns.resolver.Resolver')
367     def test_get_resolvconf_ns_default(self, mock_dns_resolve):
368         attrs = {'query.return_value': ["test"]}
369         mock_dns_resolve.configure_mock(**attrs)
370
371         m = mock.Mock()
372         attrs = {'readline.side_effect': self.readline_side}
373         m.configure_mock(**attrs)
374
375         with mock.patch("__builtin__.open") as mo:
376             mo.return_value = m
377             self.assertEqual(functest_utils.get_resolvconf_ns(),
378                              self.test_ip[1:])
379
380     def _get_environ(self, var):
381         if var == 'INSTALLER_TYPE':
382             return self.installer
383         elif var == 'DEPLOY_SCENARIO':
384             return self.scenario
385         return var
386
387     def test_get_ci_envvars_default(self):
388         with mock.patch('os.environ.get',
389                         side_effect=self._get_environ):
390             dic = {"installer": self.installer,
391                    "scenario": self.scenario}
392             self.assertDictEqual(functest_utils.get_ci_envvars(), dic)
393
394     def cmd_readline(self):
395         return 'test_value\n'
396
397     @mock.patch('functest.utils.functest_utils.logger.error')
398     @mock.patch('functest.utils.functest_utils.logger.info')
399     def test_execute_command_args_present_with_error(self, mock_logger_info,
400                                                      mock_logger_error):
401         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
402                 as mock_subproc_open, \
403                 mock.patch('__builtin__.open', mock.mock_open()) as mopen:
404
405             FunctestUtilsTesting.readline = 0
406
407             mock_obj = mock.Mock()
408             attrs = {'readline.side_effect': self.cmd_readline()}
409             mock_obj.configure_mock(**attrs)
410
411             mock_obj2 = mock.Mock()
412             attrs = {'stdout': mock_obj, 'wait.return_value': 1}
413             mock_obj2.configure_mock(**attrs)
414
415             mock_subproc_open.return_value = mock_obj2
416
417             resp = functest_utils.execute_command(self.cmd, info=True,
418                                                   error_msg=self.error_msg,
419                                                   verbose=True,
420                                                   output_file=self.output_file)
421             self.assertEqual(resp, 1)
422             msg_exec = ("Executing command: '%s'" % self.cmd)
423             mock_logger_info.assert_called_once_with(msg_exec)
424             mopen.assert_called_once_with(self.output_file, "w")
425             mock_logger_error.assert_called_once_with(self.error_msg)
426
427     @mock.patch('functest.utils.functest_utils.logger.info')
428     def test_execute_command_args_present_with_success(self, mock_logger_info,
429                                                        ):
430         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
431                 as mock_subproc_open, \
432                 mock.patch('__builtin__.open', mock.mock_open()) as mopen:
433
434             FunctestUtilsTesting.readline = 0
435
436             mock_obj = mock.Mock()
437             attrs = {'readline.side_effect': self.cmd_readline()}
438             mock_obj.configure_mock(**attrs)
439
440             mock_obj2 = mock.Mock()
441             attrs = {'stdout': mock_obj, 'wait.return_value': 0}
442             mock_obj2.configure_mock(**attrs)
443
444             mock_subproc_open.return_value = mock_obj2
445
446             resp = functest_utils.execute_command(self.cmd, info=True,
447                                                   error_msg=self.error_msg,
448                                                   verbose=True,
449                                                   output_file=self.output_file)
450             self.assertEqual(resp, 0)
451             msg_exec = ("Executing command: '%s'" % self.cmd)
452             mock_logger_info.assert_called_once_with(msg_exec)
453             mopen.assert_called_once_with(self.output_file, "w")
454
455     @mock.patch('functest.utils.functest_utils.logger.info')
456     def test_execute_command_args_missing_with_success(self, mock_logger_info,
457                                                        ):
458         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
459                 as mock_subproc_open:
460
461             FunctestUtilsTesting.readline = 2
462
463             mock_obj = mock.Mock()
464             attrs = {'readline.side_effect': self.cmd_readline()}
465             mock_obj.configure_mock(**attrs)
466
467             mock_obj2 = mock.Mock()
468             attrs = {'stdout': mock_obj, 'wait.return_value': 0}
469             mock_obj2.configure_mock(**attrs)
470
471             mock_subproc_open.return_value = mock_obj2
472
473             resp = functest_utils.execute_command(self.cmd, info=False,
474                                                   error_msg="",
475                                                   verbose=False,
476                                                   output_file=None)
477             self.assertEqual(resp, 0)
478
479     @mock.patch('functest.utils.functest_utils.logger.error')
480     def test_execute_command_args_missing_with_error(self, mock_logger_error,
481                                                      ):
482         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
483                 as mock_subproc_open:
484
485             FunctestUtilsTesting.readline = 2
486             mock_obj = mock.Mock()
487             attrs = {'readline.side_effect': self.cmd_readline()}
488             mock_obj.configure_mock(**attrs)
489
490             mock_obj2 = mock.Mock()
491             attrs = {'stdout': mock_obj, 'wait.return_value': 1}
492             mock_obj2.configure_mock(**attrs)
493
494             mock_subproc_open.return_value = mock_obj2
495
496             resp = functest_utils.execute_command(self.cmd, info=False,
497                                                   error_msg="",
498                                                   verbose=False,
499                                                   output_file=None)
500             self.assertEqual(resp, 1)
501
502     def _get_functest_config(self, var):
503         return var
504
505     @mock.patch('functest.utils.functest_utils.logger.error')
506     def test_get_dict_by_test(self, mock_logger_error):
507         with mock.patch('__builtin__.open', mock.mock_open()), \
508                 mock.patch('functest.utils.functest_utils.yaml.safe_load') \
509                 as mock_yaml, \
510                 mock.patch('functest.utils.functest_utils.get_testcases_'
511                            'file_dir'):
512             mock_obj = mock.Mock()
513             attrs = {'get.return_value': [{'testcases': [self.testcase_dict]}]}
514             mock_obj.configure_mock(**attrs)
515
516             mock_yaml.return_value = mock_obj
517
518             self.assertDictEqual(functest_utils.
519                                  get_dict_by_test(self.testname),
520                                  self.testcase_dict)
521
522     @mock.patch('functest.utils.functest_utils.get_dict_by_test')
523     def test_get_criteria_by_test_default(self, mock_get_dict_by_test):
524         mock_get_dict_by_test.return_value = self.testcase_dict
525         self.assertEqual(functest_utils.get_criteria_by_test(self.testname),
526                          self.criteria)
527
528     @mock.patch('functest.utils.functest_utils.get_dict_by_test')
529     def test_get_criteria_by_test_failed(self, mock_get_dict_by_test):
530         mock_get_dict_by_test.return_value = None
531         self.assertIsNone(functest_utils.get_criteria_by_test(self.testname))
532
533     def test_get_parameter_from_yaml_failed(self):
534         self.file_yaml['general'] = None
535         with mock.patch('__builtin__.open', mock.mock_open()), \
536                 mock.patch('functest.utils.functest_utils.yaml.safe_load') \
537                 as mock_yaml, \
538                 self.assertRaises(ValueError) as excep:
539             mock_yaml.return_value = self.file_yaml
540             functest_utils.get_parameter_from_yaml(self.parameter,
541                                                    self.test_file)
542             self.assertTrue(("The parameter %s is not"
543                              " defined in config_functest.yaml" %
544                              self.parameter) in excep.exception)
545
546     def test_get_parameter_from_yaml_default(self):
547         with mock.patch('__builtin__.open', mock.mock_open()), \
548                 mock.patch('functest.utils.functest_utils.yaml.safe_load') \
549                 as mock_yaml:
550             mock_yaml.return_value = self.file_yaml
551             self.assertEqual(functest_utils.
552                              get_parameter_from_yaml(self.parameter,
553                                                      self.test_file),
554                              'test_image_name')
555
556     @mock.patch('functest.utils.functest_utils.get_parameter_from_yaml')
557     def test_get_functest_config_default(self, mock_get_parameter_from_yaml):
558         with mock.patch.dict(os.environ,
559                              {'CONFIG_FUNCTEST_YAML': self.config_yaml}):
560             functest_utils.get_functest_config(self.parameter)
561             mock_get_parameter_from_yaml. \
562                 assert_called_once_with(self.parameter,
563                                         self.config_yaml)
564
565     def test_check_success_rate_default(self):
566         with mock.patch('functest.utils.functest_utils.get_criteria_by_test') \
567                 as mock_criteria:
568             mock_criteria.return_value = self.criteria
569             resp = functest_utils.check_success_rate(self.case_name,
570                                                      self.success_rate)
571             self.assertEqual(resp, 'PASS')
572
573     def test_check_success_rate_failed(self):
574         with mock.patch('functest.utils.functest_utils.get_criteria_by_test') \
575                 as mock_criteria:
576             mock_criteria.return_value = self.criteria
577             resp = functest_utils.check_success_rate(self.case_name,
578                                                      3.0)
579             self.assertEqual(resp, 'FAIL')
580
581     # TODO: merge_dicts
582
583     def test_get_testcases_file_dir(self):
584         resp = functest_utils.get_testcases_file_dir()
585         self.assertEqual(resp,
586                          "/home/opnfv/repos/functest/"
587                          "functest/ci/testcases.yaml")
588
589     def test_get_functest_yaml(self):
590         with mock.patch('__builtin__.open', mock.mock_open()), \
591                 mock.patch('functest.utils.functest_utils.yaml.safe_load') \
592                 as mock_yaml:
593             mock_yaml.return_value = self.file_yaml
594             resp = functest_utils.get_functest_yaml()
595             self.assertEqual(resp, self.file_yaml)
596
597     @mock.patch('functest.utils.functest_utils.logger.info')
598     def test_print_separator(self, mock_logger_info):
599         functest_utils.print_separator()
600         mock_logger_info.assert_called_once_with("======================="
601                                                  "=======================")
602
603
604 if __name__ == "__main__":
605     unittest.main(verbosity=2)