From 31534f7bbb3c8a7962867fe8df91a7af8e5fb63e Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Thu, 31 Mar 2022 21:58:18 +0530 Subject: [PATCH] Add draft screen, helper widgets and Test --- src/bitmessagekivy/baseclass/draft.py | 58 +++++++++++++++++++ src/bitmessagekivy/main.kv | 2 + src/bitmessagekivy/screens_data.json | 5 ++ .../tests/test_draft_message.py | 14 +++++ 4 files changed, 79 insertions(+) create mode 100644 src/bitmessagekivy/baseclass/draft.py diff --git a/src/bitmessagekivy/baseclass/draft.py b/src/bitmessagekivy/baseclass/draft.py new file mode 100644 index 00000000..1b3ddf21 --- /dev/null +++ b/src/bitmessagekivy/baseclass/draft.py @@ -0,0 +1,58 @@ +# pylint: disable=unused-argument, import-error, too-many-arguments +# pylint: disable=unnecessary-comprehension, no-member, no-name-in-module + +""" +draft.py +============== + +Draft screen + +""" +from kivy.clock import Clock +from kivy.properties import ( + ListProperty, + StringProperty +) +from kivy.uix.screenmanager import Screen +from kivy.app import App +from pybitmessage.bitmessagekivy.baseclass.common import ( + show_limited_cnt, empty_screen_label, + kivy_state_variables +) +import logging +logger = logging.getLogger('default') + + +class Draft(Screen): + """Draft screen class for kivy Ui""" + + data = ListProperty() + account = StringProperty() + queryreturn = ListProperty() + has_refreshed = True + label_str = "yet no message for this account!!!!!!!!!!!!!" + + def __init__(self, *args, **kwargs): + """Method used for storing draft messages""" + super(Draft, self).__init__(*args, **kwargs) + self.kivy_state = kivy_state_variables() + if self.kivy_state.selected_address == '': + if App.get_running_app().identity_list: + self.kivy_state.selected_address = App.get_running_app().identity_list[0] + Clock.schedule_once(self.init_ui, 0) + + def init_ui(self, dt=0): + """Clock Schedule for method draft accounts""" + self.load_draft() + logger.debug(dt) + + def load_draft(self, where="", what=""): + """Load draft list for Draft messages""" + self.set_draft_count('0') + self.ids.ml.add_widget(empty_screen_label(self.label_str)) + + @staticmethod + def set_draft_count(Count): + """Set the count of draft mails""" + draftCnt_obj = App.get_running_app().root.ids.content_drawer.ids.draft_cnt + draftCnt_obj.ids.badge_txt.text = show_limited_cnt(int(Count)) diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index 06963eac..09acab08 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -242,6 +242,8 @@ MDNavigationLayout: id:id_trash Allmails: id:id_allmail + Draft: + id:id_draft MDNavigationDrawer: id: nav_drawer diff --git a/src/bitmessagekivy/screens_data.json b/src/bitmessagekivy/screens_data.json index ecb60090..211a26a0 100644 --- a/src/bitmessagekivy/screens_data.json +++ b/src/bitmessagekivy/screens_data.json @@ -60,5 +60,10 @@ "kv_string": "maildetail", "name_screen": "mailDetail", "Import": "from pybitmessage.bitmessagekivy.baseclass.maildetail import MailDetail" + }, + "Draft": { + "kv_string": "draft", + "name_screen": "draft", + "Import": "from pybitmessage.bitmessagekivy.baseclass.draft import Draft" } } diff --git a/src/bitmessagekivy/tests/test_draft_message.py b/src/bitmessagekivy/tests/test_draft_message.py index 23844640..9a2efed8 100644 --- a/src/bitmessagekivy/tests/test_draft_message.py +++ b/src/bitmessagekivy/tests/test_draft_message.py @@ -12,6 +12,20 @@ class DraftMessage(TeleniumTestProcess): test_subject = 'Test Subject text' test_body = 'Hey, This is draft Message Body' + @ordered + def test_draft_screen(self): + """Test draft screen is open""" + # Checking current Screen(Inbox screen) + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # Method to open side navbar + self.open_side_navbar() + # this is for opening Draft screen + self.cli.wait_click('//NavigationItem[@text=\"Draft\"]', timeout=2) + # Checking the drawer is in 'closed' state + self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) + # Checking Draft Screen + self.assertExists("//ScreenManager[@current=\"draft\"]", timeout=5) + @skip_screen_checks @ordered def test_save_message_to_draft(self):