Exemplo n.º 1
0
    def __init__(self, sys_argv):
        super(App, self).__init__(sys_argv)
        # Set Application Default Settings
        QtCore.QCoreApplication.setOrganizationName("DreamingKeldi")
        QtCore.QCoreApplication.setApplicationName("MailAutomate")

        self.main_view = MainView()
        self.main_view.show()
        self.main_ctrl = MainController(None, self.main_view)
Exemplo n.º 2
0
    def __init__(self, sys_argv):
        super(App, self).__init__(sys_argv)

        # covnert from ui to py for view
        # os.system("pyuic5 view/app.ui -o view/main_view_ui.py")
        self.model = Medusa()
        self.main_controller = MainController(self.model)
        self.main_view = MainView(self.model, self.main_controller)
        self.main_view.show()
Exemplo n.º 3
0
    def test_build_window_content_label(self):
        """ Unit test for view.main_view.Model.build_window's content_label feature """

        with patch('view.main_view.tk.Label',
                   new_callable=PropertyMock) as mock_label:
            root = tk.Tk()
            view = MainView(master=root)
            view.build_window()
            mock_label.assert_has_calls([
                call().__setitem__('text', 'Welcome to Tiny Ticker news feed'),
                call().pack(side="top"),
            ],
                                        any_order=True)
Exemplo n.º 4
0
def main():
    root = tkinter.Tk()
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)

    audio_model = AudioManager()
    survey_model = SurveyManager()
    eda_model = EDAManager()
    view = MainView(root)
    controller = SyncController(audio_model, survey_model, eda_model, view)
    view.register_observer(controller)

    root.mainloop()
Exemplo n.º 5
0
    def test_call_ten_second_loop(self, mock_loop, mock_parser):
        """ Unit test for controller.tiny_ticker.main. Tests the call to the ten second loop """

        root = tk.Tk()
        test_view = MainView(master=root)
        main(test_view)
        mock_loop.assert_called_with('www.fakeurl.com',)
Exemplo n.º 6
0
    def test_call_ticker_argument_parser(self, mock_arg_parser, mock_parser):
        """ Unit test for controller.tiny_ticker.main. Tests the call to the argument parser"""

        root = tk.Tk()
        test_view = MainView(master=root)
        main(test_view)
        mock_arg_parser.assert_called()
    def test_build_window_content_label(self):
        """
        Unit test for view.main_view.Model.build_window.

        Tests the creation of the content_label feature
        """

        with patch('view.main_view.tk.Label', new_callable=PropertyMock) as mock_label:
            root = tk.Tk()
            self.view = MainView(master=root)
            self.view._build_window("Test Title", "https://github.com/int-thumbWar-1-2-3-4/Python-RSS-ticker")

            mock_label.assert_has_calls([
                call().__setitem__('text', 'Welcome to Tiny Ticker news feed'),
                call().pack(side="top"),
            ], any_order=True)
Exemplo n.º 8
0
def call_switch_display(main_view: MainView, feed_manager: FeedManager):
    """
    controller.tiny_ticker.call_switch_display

    Requests the next article from the feed_manager and prompts the view to display it.

    Arguments:
        main_view -- the gui view which will display the next article
        feed_manager -- the feed_manager which holds the contents of all of the feeds currently downloaded.
    """

    tt_logger.debug('call_switch_display')

    article = feed_manager.get_next_article()

    main_view.display_entry(article.title, article.link)
Exemplo n.º 9
0
    def initUI(self):
        self.setWindowTitle(self.title)
        self.main_layout = QVBoxLayout(self)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.main_view = MainView(self, self.main_layout, self.controller)

        self.showMaximized()
Exemplo n.º 10
0
 def test_call_parse(self, mock_parser):
     """ Unit test for controller.tiny_ticker.main. Tests the call to the model's feedmanager.parse """
     fake_url = ['www.fakeurl.com']
     sys.argv = ['test', '--url', fake_url[0]]
     root = tk.Tk()
     test_view = MainView(master=root)
     main(test_view)
     mock_parser.assert_called_with(fake_url[0])
Exemplo n.º 11
0
def main(main_view: MainView):
    """
    controller.tiny_ticker.main

    Gathers command-line args, loads feeds into the model, and initiates the title loop.

    Arguments:
        mainView -- the gui view which displays feed articles
    """

    tt_logger.debug('main')

    urls = arguments.url
    feed_manager = create_feed_manager(urls.pop(0))
    main_view.attach_new_feed_menu(feed_manager, call_new_feed)
    ten_second_loop(main_view, arguments.timer, feed_manager)

    for u in urls:
        call_new_feed(feed_manager, u)
Exemplo n.º 12
0
class MainController:
    def __init__(self):
        self.__stack_controller = StackController()
        self.__queue_controller = QueueController()
        self.__main_view = MainView()

    def start(self):
        screen_opened = True
        while screen_opened:
            button, values = self.__main_view.start_screen()
            if button == "Stack":
                self.__main_view.close()
                self.__stack_controller.stack_options()

            elif button == "Queue":
                self.__main_view.close()
                self.__queue_controller.queue_options()

            else:
                screen_opened = False

            self.__main_view.close()
 def setUp(cls):
     root = tk.Tk()
     cls.test_view = MainView(master=root)
Exemplo n.º 14
0
def main_ui():
    """ Main function. """
    # Create instances of the model and the controller
    view = MainView()
    model = None
    MainController(model=model, view=view)
Exemplo n.º 15
0
 def __init__(self):
     self.__stack_controller = StackController()
     self.__queue_controller = QueueController()
     self.__main_view = MainView()
Exemplo n.º 16
0
from tkinter import *

from controller.book_controller import BookController
from controller.calculator_controller import CalculatorController
from dao.book_repository import BookRepository
from entity.book import Book
from service.book_service import BookService
from service.feet_to_meter_service import FeetToMeterService
from view.main_view import MainView
from view.utils.tkinter_utils import center_resize_window

if __name__ == "__main__":
    root = Tk()
    center_resize_window(root, 800, 400)
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)

    # Configure doamin repos and services
    books_repo = BookRepository("books.json", Book)
    book_service = BookService(books_repo)
    book_controller = BookController(book_service)
    book_controller.reload_books()

    main_view = MainView(root, book_controller)
    book_controller.view = main_view

    # Start the app event loop
    root.mainloop()
class TestMainView(unittest.TestCase):
    """Testing Class for view.main_view."""

    @classmethod
    def setUp(cls):
        root = tk.Tk()
        cls.test_view = MainView(master=root)

    @classmethod
    def tearDown(cls):
        cls.test_view.destroy()


    def test_build_window_winfo_toplevel(self):
        """
        Unit test for view.main_view.Model.build_window.

        Tests the first line of code in this function.
        """

        expected_text = 'Tiny Ticker'
        self.test_view._build_window("test_title", "test_link")
        self.assertTrue(self.test_view.winfo_toplevel().title, expected_text)


    def test_build_window_content_label(self):
        """
        Unit test for view.main_view.Model.build_window.

        Tests the creation of the content_label feature
        """

        with patch('view.main_view.tk.Label', new_callable=PropertyMock) as mock_label:
            root = tk.Tk()
            self.view = MainView(master=root)
            self.view._build_window("Test Title", "https://github.com/int-thumbWar-1-2-3-4/Python-RSS-ticker")

            mock_label.assert_has_calls([
                call().__setitem__('text', 'Welcome to Tiny Ticker news feed'),
                call().pack(side="top"),
            ], any_order=True)

    def test_display_entry(self):
        """Unit test for view.main_view.Model.build_window."""

        fake_title = 'Man explodes'
        fake_link = 'www.virus.com'

        self.test_view.display_entry(fake_title, fake_link)
        self.test_view.content_label = PropertyMock()
        self.assertTrue(self.test_view.content_label.call().__setitem__('text', fake_title))

    @patch('view.main_view.webbrowser.open_new')
    def test_open_article(self, mock_open_new):
        """Unit test for view.main_view.MainView.open_article."""

        test_link = 'www.goesnowhere.com'
        self.test_view._open_article(test_link)
        mock_open_new.assert_called_with(test_link)

    def test_change_windows_background(self):
        """
        Unit test for view.main_view.MainView.change_window.

        Test background color change.
        """

        self.test_view._change_window('bg', 'blue')
        self.assertEqual(self.test_view.content_label['bg'], 'blue')

    def test_change_font_size(self):
        """
        Unit test for view.main_view.MainView.change_window.

        Test font size change.
        """

        self.test_view._change_window('font', '9')
        self.assertEqual(self.test_view.content_label['font'], '9')

    def test_change_font_color(self):
        """
        Unit test for view.main_view.MainView.change_window.

        Test font color change.
        """

        self.test_view._change_window('fg', 'red')
        self.assertEqual(self.test_view.content_label['fg'], 'red')

    @patch('view.main_view.simpledialog')
    @patch('model.feed_manager.FeedManager')
    @patch('controller.tiny_ticker.call_new_feed')
    def test_prompt_new_feed(self, mock_simpledialog, mock_feed_manager, mock_call_new_feed):
        """
        Unit test for view.main_view.MainView.test_prompt_new_feed.

        Test adding a new feed during runtime.
        """

        mock_simpledialog.askstring.return_value = "https://www.theguardian.com/us/rss"
        self.test_view._prompt_new_feed(mock_feed_manager, mock_call_new_feed)
        mock_call_new_feed.assert_called()
Exemplo n.º 18
0
 def setUp(cls):
     """Test.test_tiny_ticker.TestTinyTicker.setUp."""
     root = tk.Tk()
     cls.test_view = MainView(master=root)
Exemplo n.º 19
0
class MainController():
    def __init__(self):
        self.view = MainView()

    def start_session(self):
        # profile may be:
        # - a string if loging is invalid OR user is ADMIN
        # - an Account object, if a customer performed a successful login
        # - a person object, if a manager performed a successful login
        profile = self.login()
        if profile == 'invalid':
            return

        option = 1
        while option > 0:
            #Shows main menu according to profile
            option = self.view.show_main_menu(profile)
            #client - account deposit
            if option == 1:
                AccountController().create_transaction(profile, 'Deposit')
            #client - account withdrawal
            elif option == 2:
                AccountController().create_transaction(profile, 'Withdrawal')
            #client - account balance
            elif option == 3:
                AccountController().list_balance(profile)
            #client - account history
            elif option == 4:
                AccountController().list_statement(profile)
            #admin - create branch
            elif option == 100:
                BranchController().create_branch()
            #admin - list branches
            elif option == 101:
                BranchController().list_branches()
            #admin - create manager
            elif option == 102:
                PersonController().create_person('Manager')
            #admin - list managers
            elif option == 103:
                PersonController().list_people('Manager')
            #manager-create account
            elif option == 200:
                AccountController().create_account()
            #manager-list accounts
            elif option == 201:
                AccountController().list_client_accounts()

    def login(self):
        user, password = LoginView().show_login()
        #if user in ['admin', 'manager']:
        if user == 'admin':
            return user

        #Validates login with DB.
        person_dal = PersonDAL()
        person = person_dal.select_by_login(user)

        if person != None:
            valid_login = person.login == user and person.password == password
            if valid_login and person.role == 'C':
                account_dal = ClientAccountDAL()
                client_account = account_dal.select_client_account(person.id)
                print('select exec')
                if client_account != None:
                    return client_account

            if valid_login and person.role == 'M':
                return person

        self.view.show_message('Error', 'Invalid login.', True)
        return 'invalid'
Exemplo n.º 20
0
 def __init__(self):
     self.view = MainView()
Exemplo n.º 21
0
#!/usr/bin/env python3

from view.base_view import BaseView
from view.account_view import AccountView
from view.branch_view import BranchView
from view.login_view import LoginView
from view.person_view import PersonView
from view.main_view import MainView

if __name__ == '__main__':
    # base_view = BaseView(70)
    # base_view.print_header('UNIT TEST')

    # account_view = AccountView()
    # account_view.create_account()
    # # account_view.create_transaction('Deposit')

    # branch_view = BranchView()
    # branch_view.create_branch()

    # login_view = LoginView()
    # login_view.show_login()

    # person_view = PersonView()
    # person_view.create_person('Manager')

    main_view = MainView()
    main_view.show_main_menu('admin')
    input()

    main_view.show_admin_menu()
Exemplo n.º 22
0
import settings
from object.factory import GameObjectFactory
from view.main_view import MainView

# Initial Game
pygame.init()
pygame.display.set_caption('StarCraft')

shoot_frequency = 0
enemy_frequency = 0
score = 0
player_down_index = 16
clock = pygame.time.Clock()

main_view = MainView(settings)
sprite_family = GameObjectFactory(settings)
player = sprite_family.create_player()
enemy = sprite_family.create_enemy()
enemies1 = pygame.sprite.Group()
enemies_down = pygame.sprite.Group()

# Start Game
running = True
while running:
    # Set max fps is 60
    clock.tick(60)

    # Draw the background
    main_view.screen.fill(0)
    main_view.screen.blit(main_view.background, (0, 0))