Esempio n. 1
0
    def test_add_bookmark(self, monkeypatch):
        fcontent = '{"123":"abc"}'
        with mock.patch.object(builtins, 'open',
                               mock.mock_open(read_data=fcontent)):
            monkeypatch.setattr('sys.argv', ['focli', '-a', '157'])
            assert focli.main() == 0

            monkeypatch.setattr('sys.argv', ['focli', '-a'])
            assert focli.main() == 1
Esempio n. 2
0
    def test_add_bookmark(self, monkeypatch):
        fcontent = '{"123":"abc"}'
        with mock.patch.object(builtins, 'open',
                               mock.mock_open(read_data=fcontent)):
            monkeypatch.setattr('sys.argv', ['focli', '-a', '157'])
            assert focli.main() == 0

            monkeypatch.setattr('sys.argv', ['focli', '-a'])
            assert focli.main() == 1
Esempio n. 3
0
    def test_main_show_stops(self, monkeypatch):
        monkeypatch.setattr('sys.argv', ['focli', '157', '123', '420'])

        def mock_return(a):
            return True

        monkeypatch.setattr('focli.focli.show_stops', mock_return)
        assert focli.main() is True
Esempio n. 4
0
    def test_main_list_bookmarks(self, monkeypatch):
        monkeypatch.setattr('sys.argv', ['focli', '-l'])

        def mock_return():
            return True

        monkeypatch.setattr('focli.focli.list_bookmarks', mock_return)
        assert focli.main() is True
Esempio n. 5
0
    def test_main_del_bookmark(self, monkeypatch):
        monkeypatch.setattr('sys.argv', ['focli', '-d', '157'])

        def mock_return(a):
            return True

        monkeypatch.setattr('focli.focli.del_bookmark', mock_return)
        assert focli.main() is True
Esempio n. 6
0
    def test_main_exception(self, monkeypatch):
        monkeypatch.setattr('sys.argv', ['focli', 'nonexistent'])

        def mock_exception(a):
            raise FoliStopNameException("message")

        monkeypatch.setattr('focli.focli.show_stops', mock_exception)

        assert focli.main() == 1
Esempio n. 7
0
    def test_show_stops(self, monkeypatch):
        def mock_init(*args, **kwargs):
            return None

        def mock_func(*args):
            return True

        monkeypatch.setattr('focli.foline.FoliPrint.__init__', mock_init)
        monkeypatch.setattr('focli.foline.FoliPrint.print_lines', mock_func)
        monkeypatch.setattr('sys.argv', ['focli', '157'])
        assert focli.main() == 0
        fcontent = '{"123":"abc"}'
        monkeypatch.setattr('sys.argv', ['focli'])
        with mock.patch.object(builtins, 'open',
                               mock.mock_open(read_data=fcontent)):
            assert focli.main() == 0
        with mock.patch.object(builtins, 'open',
                               mock.mock_open(read_data="{}")):
            assert focli.main() == 1
Esempio n. 8
0
    def test_main_show_stops(self, monkeypatch):
        monkeypatch.setattr('sys.argv',
                            ['focli', '157', '123', '420'])

        def mock_return(a):
            return True

        monkeypatch.setattr('focli.focli.show_stops',
                            mock_return)
        assert focli.main() is True
Esempio n. 9
0
    def test_main_list_bookmarks(self, monkeypatch):
        monkeypatch.setattr('sys.argv',
                            ['focli', '-l'])

        def mock_return():
            return True

        monkeypatch.setattr('focli.focli.list_bookmarks',
                            mock_return)
        assert focli.main() is True
Esempio n. 10
0
    def test_main_del_bookmark(self, monkeypatch):
        monkeypatch.setattr('sys.argv',
                            ['focli', '-d', '157'])

        def mock_return(a):
            return True

        monkeypatch.setattr('focli.focli.del_bookmark',
                            mock_return)
        assert focli.main() is True
Esempio n. 11
0
    def test_show_stops(self, monkeypatch):
        def mock_init(*args, **kwargs):
            return None

        def mock_func(*args):
            return True

        monkeypatch.setattr('focli.foline.FoliPrint.__init__', mock_init)
        monkeypatch.setattr('focli.foline.FoliPrint.print_lines', mock_func)
        monkeypatch.setattr('sys.argv', ['focli', '157'])
        assert focli.main() == 0
        fcontent = '{"123":"abc"}'
        monkeypatch.setattr('sys.argv', ['focli'])
        with mock.patch.object(builtins, 'open',
                               mock.mock_open(read_data=fcontent)):
            assert focli.main() == 0
        with mock.patch.object(builtins, 'open',
                               mock.mock_open(read_data="{}")):
            assert focli.main() == 1
Esempio n. 12
0
    def test_main_exception(self, monkeypatch):
        monkeypatch.setattr('sys.argv',
                            ['focli', 'nonexistent'])

        def mock_exception(a):
            raise FoliStopNameException("message")

        monkeypatch.setattr('focli.focli.show_stops',
                            mock_exception)

        assert focli.main() == 1
Esempio n. 13
0
def main():
    return focli.main()
Esempio n. 14
0
def main():
    return focli.main()