Files
test/keywords/linux/date/date_keywords.py
Swapna Gorre 8d0b61e97b Migrate backup test cases under test_verify_backup_file.py
- migrate backup test cases from old framework to new framework.
  - Add test case for test_verify_backup_central,
    test_verify_backup_local_custom_path.

Change-Id: I6107c02d5aa383ec94b5c9c7bf76eeffa6e57d78
Signed-off-by: Swapna Gorre <swapna.gorre@windriver.com>
2025-03-25 11:54:42 -04:00

32 lines
994 B
Python

from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword
class DateKeywords(BaseKeyword):
"""
Date Keywords class
"""
def __init__(self, ssh_connection: SSHConnection):
self.ssh_connection = ssh_connection
def get_timezone(self):
"""
Returns the timezone using a linux system command
"""
date = self.ssh_connection.send("date +%Z")
self.validate_success_return_code(self.ssh_connection)
# can only be one line in the response + remove any trailing \n
return date[0].strip()
def get_current_date(self):
"""
Returns the current date in the format YYYY-MM-DD using a linux system command
"""
current_date = self.ssh_connection.send('date "+%Y-%m-%d"')
self.validate_success_return_code(self.ssh_connection)
# can only be one line in the response + remove any trailing \n
return current_date[0].strip()