Example #1
0
    def test_recover_user_id_2(self):
        assert self.config()["user_id"] is not None
        MnemosyneTest.teardown(self)

        open(
            os.path.join(os.getcwd(), "dot_test", "history",
                         "userid_machine_001.bz2"), "w")
        os.remove(os.path.join(os.getcwd(), "dot_test", "config.db"))

        self.mnemosyne = Mnemosyne(upload_science_logs=False,
                                   interested_in_old_reps=True,
                                   asynchronous_database=True)
        self.mnemosyne.components.insert(
            0,
            ("mnemosyne.libmnemosyne.gui_translators.gettext_gui_translator",
             "GetTextGuiTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.gui_for_component["ScheduledForgottenNew"] = \
            [("mnemosyne_test", "TestReviewWidget")]
        self.mnemosyne.initialise(os.path.abspath("dot_test"),
                                  automatic_upgrades=False)
        self.mnemosyne.start_review()

        assert self.config()["user_id"] == "userid"
Example #2
0
 def setup(self):
     MnemosyneTest.setup(self)
     from mnemosyne.libmnemosyne.card_types.cloze import ClozePlugin
     for plugin in self.plugins():
         if isinstance(plugin, ClozePlugin):
             plugin.activate()
             break
Example #3
0
 def teardown(self):
     if os.path.exists("a.ogg"):
         os.remove("a.ogg")
     if os.path.exists("b.ogg"):
         os.remove("b.ogg")
     if os.path.exists(unichr(40960) + u"a.ogg"):
         os.remove(unichr(40960) + u"a.ogg")
     MnemosyneTest.teardown(self)
Example #4
0
 def teardown(self):
     filename = os.path.join(os.getcwd(), "dot_test", "default.db_media", "a.png")
     if os.path.exists(filename):
         os.remove(filename)
     filename = os.path.join(os.getcwd(), "dot_test", "test.txt")
     if os.path.exists(filename):
         os.remove(filename)
     MnemosyneTest.teardown(self)
Example #5
0
 def teardown(self):
     MnemosyneTest.teardown(self)
     if os.path.exists(self.merge_db_path + "-journal"):
         os.remove(self.merge_db_path + "-journal")
     if os.path.exists(self.merge_db_tmppath):
         os.remove(self.merge_db_tmppath)
     if os.path.exists(self.merge_db_tmppath + "-journal"):
         os.remove(self.merge_db_tmppath + "-journal")
 def teardown(self):
     filename = \
         os.path.join(os.getcwd(), "dot_test", "default.db_media", "a.png")
     if os.path.exists(filename):
         os.remove(filename)
     filename = \
         os.path.join(os.getcwd(), "dot_test", "test.txt")
     if os.path.exists(filename):
         os.remove(filename)
     MnemosyneTest.teardown(self)
Example #7
0
 def teardown(self):
     filename = os.path.join(os.getcwd(), "tests", "files", "a.png")
     if os.path.exists(filename):
         os.remove(filename)
     filename = os.path.join(os.getcwd(), "tests", "files", "a.ogg")
     if os.path.exists(filename):
         os.remove(filename)
     dirname = os.path.join(os.getcwd(), "tests", "files", "figs")
     if os.path.exists(dirname):
         shutil.rmtree(dirname)
     MnemosyneTest.teardown(self)
Example #8
0
 def teardown(self):
     if os.path.exists("a.ogg"):
         os.remove("a.ogg")
     if os.path.exists("b.ogg"):
         os.remove("b.ogg")
     if os.path.exists("c.ogg"):
         os.remove("c.ogg")
     if os.path.exists(chr(40960) + "a.ogg"):
         os.remove(chr(40960) + "a.ogg")
     if os.path.exists("sub"):
         shutil.rmtree("sub")
     if os.path.exists("_keep"):
         shutil.rmtree("_keep")
     MnemosyneTest.teardown(self)
Example #9
0
 def teardown(self):
     if os.path.exists("a.ogg"):
         os.remove("a.ogg")
     if os.path.exists("b.ogg"):
         os.remove("b.ogg")
     if os.path.exists("c.ogg"):
         os.remove("c.ogg")
     if os.path.exists(unichr(40960) + u"a.ogg"):
         os.remove(unichr(40960) + u"a.ogg")
     if os.path.exists("sub"):
         shutil.rmtree("sub")
     if os.path.exists("_keep"):
         shutil.rmtree("_keep")
     MnemosyneTest.teardown(self)
Example #10
0
    def test_log_upload_bad_server(self):
        # Most reliable way of setting this variable is throug config.py, otherwise
        # it will stay alive in a dangling imported userconfig.
        config_py_file = os.path.join(self.mnemosyne.config().config_dir,
                                      "config.py")
        f = open(config_py_file, "w")
        print("science_server = \"noserver:80\"", file=f)
        f.close()

        machine_id_file = os.path.join(self.mnemosyne.config().config_dir,
                                       "machine.id")
        f = open(machine_id_file, "w")
        print("TESTMACHINE", file=f)
        f.close()
        self.config().change_user_id("UPLOADTEST")
        self.config()["max_log_size_before_upload"] = 1
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True,
                                   interested_in_old_reps=True,
                                   asynchronous_database=True)
        self.mnemosyne.components.insert(
            0,
            ("mnemosyne.libmnemosyne.gui_translators.gettext_gui_translator",
             "GetTextGuiTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.gui_for_component["ScheduledForgottenNew"] = \
            [("mnemosyne_test", "TestReviewWidget")]
        self.mnemosyne.initialise(os.path.abspath("dot_test"),
                                  automatic_upgrades=False)
        self.mnemosyne.start_review()
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True,
                                   interested_in_old_reps=True,
                                   asynchronous_database=True)
        self.mnemosyne.components.insert(
            0,
            ("mnemosyne.libmnemosyne.gui_translators.gettext_gui_translator",
             "GetTextGuiTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.gui_for_component["ScheduledForgottenNew"] = \
            [("mnemosyne_test", "TestReviewWidget")]
        self.mnemosyne.initialise(os.path.abspath("dot_test"),
                                  automatic_upgrades=False)
        self.mnemosyne.start_review()
Example #11
0
 def teardown(self):
     MnemosyneTest.teardown(self)
     if os.path.exists("a.ogg"):
         os.remove("a.ogg")
     if os.path.exists("b.ogg"):
         os.remove("b.ogg")
     if os.path.exists("c.ogg"):
         os.remove("c.ogg")
     if os.path.exists(chr(40960) + "a.ogg"):
         os.remove(chr(40960) + "a.ogg")
     if os.path.exists("sub"):
         shutil.rmtree("sub")
     if os.path.exists("_keep"):
         shutil.rmtree("_keep")
     if os.path.exists("outside.db"):
         os.remove("outside.db")
     if os.path.exists("outside.db-journal"):
         os.remove("outside.db-journal")
Example #12
0
 def teardown(self):
     filename = os.path.join(os.getcwd(), "tests", "files", "basedir_bz2",
                                 "DIRECTORY_NO_LONGER_USED_BY_MNEMOSYNE2")
     if os.path.exists(filename):
         os.remove(filename)
     filename = os.path.join(os.getcwd(), "tests", "files", "a.png")
     if os.path.exists(filename):
         os.remove(filename)
     filename = os.path.join(os.getcwd(), "tests", "files", "a.ogg")
     if os.path.exists(filename):
         os.remove(filename)
     dirname = os.path.join(os.getcwd(), "tests", "files", "figs")
     if os.path.exists(dirname):
         shutil.rmtree(dirname)
     dirname = os.path.join(os.getcwd(), "tests", "files", "soundfiles")
     if os.path.exists(dirname):
         shutil.rmtree(dirname)
     MnemosyneTest.teardown(self)
Example #13
0
    def test_recover_user_id_2(self):
        assert self.config()["user_id"] is not None
        MnemosyneTest.teardown(self)

        file(os.path.join(os.getcwd(), "dot_test", "history", "userid_machine_001.bz2"), "w")
        os.remove(os.path.join(os.getcwd(), "dot_test", "config.db"))

        self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True,
            asynchronous_database=True)
        self.mnemosyne.components.insert(0,
           ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.components.append(\
            ("mnemosyne_test", "TestReviewWidget"))
        self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)

        assert self.config()["user_id"] == "userid"
Example #14
0
 def teardown(self):
     filename = os.path.join(os.getcwd(), "tests", "files", "basedir_bz2",
                                 "DIRECTORY_NO_LONGER_USED_BY_MNEMOSYNE2")
     if os.path.exists(filename):
         os.remove(filename)
     filename = os.path.join(os.getcwd(), "tests", "files", "a.png")
     if os.path.exists(filename):
         os.remove(filename)
     filename = os.path.join(os.getcwd(), "tests", "files", "a.ogg")
     if os.path.exists(filename):
         os.remove(filename)
     dirname = os.path.join(os.getcwd(), "tests", "files", "figs")
     if os.path.exists(dirname):
         shutil.rmtree(dirname)
     dirname = os.path.join(os.getcwd(), "tests", "files", "soundfiles")
     if os.path.exists(dirname):
         shutil.rmtree(dirname)
     MnemosyneTest.teardown(self)
Example #15
0
    def test_log_upload_bad_server(self):
        # Most reliable way of setting this variable is throug config.py, otherwise
        # it will stay alive in a dangling imported userconfig.
        config_py_file = os.path.join(self.mnemosyne.config().config_dir, "config.py")
        f = file(config_py_file, "w")
        print >> f, "science_server = \"noserver:80\""
        f.close()

        machine_id_file = os.path.join(self.mnemosyne.config().config_dir, "machine.id")
        f = file(machine_id_file, "w")
        print >> f, "TESTMACHINE"
        f.close()
        self.config().change_user_id("UPLOADTEST")
        self.config()["max_log_size_before_upload"] = 1
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
            asynchronous_database=True)
        self.mnemosyne.components.insert(0,
           ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.components.append(\
            ("mnemosyne_test", "TestReviewWidget"))
        self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
        self.mnemosyne.start_review()
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
            asynchronous_database=True)
        self.mnemosyne.components.insert(0,
           ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.components.append(\
            ("mnemosyne_test", "TestReviewWidget"))
        self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
        self.mnemosyne.start_review()
Example #16
0
    def test_log_upload(self):
        machine_id_file = os.path.join(self.mnemosyne.config().config_dir,
                                       "machine.id")
        f = open(machine_id_file, "w")
        print("TESTMACHINE", file=f)
        f.close()
        self.config().change_user_id("UPLOADTEST")
        self.config()["max_log_size_before_upload"] = 1
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True,
                                   interested_in_old_reps=True,
                                   asynchronous_database=True)
        self.mnemosyne.components.insert(
            0,
            ("mnemosyne.libmnemosyne.gui_translators.gettext_gui_translator",
             "GetTextGuiTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.gui_for_component["ScheduledForgottenNew"] = \
            [("mnemosyne_test", "TestReviewWidget")]
        self.mnemosyne.initialise(os.path.abspath("dot_test"),
                                  automatic_upgrades=False)
        self.mnemosyne.start_review()
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True,
                                   interested_in_old_reps=True,
                                   asynchronous_database=True)
        self.mnemosyne.components.insert(
            0,
            ("mnemosyne.libmnemosyne.gui_translators.gettext_gui_translator",
             "GetTextGuiTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.gui_for_component["ScheduledForgottenNew"] = \
            [("mnemosyne_test", "TestReviewWidget")]
        self.mnemosyne.initialise(os.path.abspath("dot_test"),
                                  automatic_upgrades=False)
        self.mnemosyne.start_review()
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True,
                                   interested_in_old_reps=True,
                                   asynchronous_database=True)
        self.mnemosyne.components.insert(
            0,
            ("mnemosyne.libmnemosyne.gui_translators.gettext_gui_translator",
             "GetTextGuiTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.gui_for_component["ScheduledForgottenNew"] = \
            [("mnemosyne_test", "TestReviewWidget")]
        self.mnemosyne.initialise(os.path.abspath("dot_test"),
                                  automatic_upgrades=False)
        self.mnemosyne.start_review()
Example #17
0
    def test_log_upload(self):
        machine_id_file = os.path.join(self.mnemosyne.config().config_dir, "machine.id")
        f = file(machine_id_file, "w")
        print >> f, "TESTMACHINE"
        f.close()
        self.config().change_user_id("UPLOADTEST")
        self.config()["max_log_size_before_upload"] = 1
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
            asynchronous_database=True)
        self.mnemosyne.components.insert(0,
           ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.components.append(\
            ("mnemosyne_test", "TestReviewWidget"))
        self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
        self.mnemosyne.start_review()
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
            asynchronous_database=True)
        self.mnemosyne.components.insert(0,
           ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.components.append(\
            ("mnemosyne_test", "TestReviewWidget"))
        self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
        self.mnemosyne.start_review()
        MnemosyneTest.teardown(self)

        self.mnemosyne = Mnemosyne(upload_science_logs=True, interested_in_old_reps=True,
            asynchronous_database=True)
        self.mnemosyne.components.insert(0,
           ("mnemosyne.libmnemosyne.translators.gettext_translator", "GetTextTranslator"))
        self.mnemosyne.components.append(\
            ("test_logging", "MyMainWidget"))
        self.mnemosyne.components.append(\
            ("mnemosyne_test", "TestReviewWidget"))
        self.mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
        self.mnemosyne.start_review()
Example #18
0
 def teardown(self):
     if os.path.exists("a.ogg"):
         os.remove("a.ogg")
     MnemosyneTest.teardown(self)
Example #19
0
 def teardown(self):
     if os.path.exists("a.ogg"):
         os.remove("a.ogg")
     MnemosyneTest.teardown(self)
Example #20
0
 def teardown(self):
     if os.path.exists(os.path.abspath("test.cards")):
         os.remove(os.path.abspath("test.cards"))
     if os.path.exists("test2.cards"):
         os.remove("test2.cards")
     MnemosyneTest.teardown(self)
 def teardown(self):
     if os.path.exists(os.path.abspath("test.cards")):
         os.remove(os.path.abspath("test.cards"))
     if os.path.exists("test2.cards"):
         os.remove("test2.cards")
     MnemosyneTest.teardown(self)