Ejemplo n.º 1
0
    def test_new_cards_vs_new_card(self):
        # Also done in test_new_card_fully_specified

        empty = self.necards()
        empty2 = self.necards()

        nid = list(raw.get_nid2mid(self.db))[0]
        deck = list(raw.get_did2deck(self.db).values())[0]

        init_dict2 = dict(
            nid=[nid],
            cdeck=deck,
            cord=0,
            cmod=123,
            cusn=5,
            cqueue="learning",
            ctype="relearn",
            civl=5,
            cfactor=17,
            clapses=89,
            cleft=15,
            cdue=178,
        )
        init_dict1 = copy.deepcopy(init_dict2)
        init_dict1["nid"] = nid

        cids = empty2.add_cards(**init_dict2, inplace=True)
        card2 = empty2.loc[cids[0]]

        cid = empty.add_card(**init_dict1, inplace=True)[0]
        card1 = empty.loc[cid]

        self.assertDictEqual(self._cards_dict(card2), self._cards_dict(card1))
Ejemplo n.º 2
0
 def test_new_cards_raises_due_default_not_new(self):
     empty = self.necards()
     nids = [1555579352896]
     deck = list(raw.get_did2deck(self.db).values())[0]
     with self.assertRaises(ValueError) as context:
         empty.add_cards(nids, deck, cqueue="learning")
     self.assertTrue("Due date can only be set" in str(context.exception))
Ejemplo n.º 3
0
    def test_new_cards_default_values(self):
        empty = self.necards()

        nid1 = 1555579352896
        nid2 = 1557223191575
        nids = [nid1, nid2]
        deck = list(raw.get_did2deck(self.db).values())[0]

        kwargs = dict(cdeck=deck)

        with self.subTest(type="default values single note"):
            self._test_new_card_default_values(empty.add_card(nid1, deck),
                                               **kwargs)
        with self.subTest(type="default values single card"):
            self._test_new_card_default_values(empty.add_card(nid1,
                                                              deck,
                                                              cord=0),
                                               **kwargs,
                                               cord=0)
        with self.subTest(type="default values several notes"):
            self._test_new_card_default_values(empty.add_cards(nids, deck),
                                               **kwargs)
        with self.subTest(type="default values several notes one cord"):
            self._test_new_card_default_values(empty.add_cards(nids,
                                                               deck,
                                                               cord=0),
                                               **kwargs,
                                               cord=0)
Ejemplo n.º 4
0
 def test_get_deck_names(self):
     for version in [0, 1]:
         with self.subTest(version=version):
             names = get_did2deck(self.version2db[version])
             self.assertTrue(
                 set(names.values()).issuperset(
                     {"Testing", "EnglishGerman"}))
Ejemplo n.º 5
0
    def test_new_card_fully_specified(self):
        empty = self.necards()
        empty_combined = self.necards()

        # Careful: Need notes of the same model!
        nid1 = 1555579352896
        nid2 = 1557223191575
        deck1 = list(raw.get_did2deck(self.db).values())[0]
        deck2 = list(raw.get_did2deck(self.db).values())[1]

        init_dict1 = dict(
            nid=nid1,
            cdeck=deck1,
            cord=0,
            cmod=123,
            cusn=5,
            cqueue="learning",
            ctype="relearn",
            civl=5,
            cfactor=17,
            clapses=89,
            cleft=15,
            cdue=178,
        )
        init_dict2 = dict(
            nid=nid2,
            cdeck=deck2,
            cord=0,
            cmod=1123,
            cusn=15,
            cqueue="due",
            ctype="review",
            civl=15,
            cfactor=117,
            clapses=189,
            cleft=115,
            cdue=1178,
        )
        init_dict_combined = dict(
            nid=[nid1, nid2],
            cdeck=[deck1, deck2],
            cord=0,
            cmod=[123, 1123],
            cusn=[5, 15],
            cqueue=["learning", "due"],
            ctype=["relearn", "review"],
            civl=[5, 15],
            cfactor=[17, 117],
            clapses=[89, 189],
            cleft=[15, 115],
            cdue=[178, 1178],
        )

        cid1 = empty.add_card(**init_dict1, inplace=True)[0]
        card1 = empty.loc[cid1]
        cid2 = empty.add_card(**init_dict2, inplace=True)[0]
        card2 = empty.loc[cid2]

        cid1, cid2 = empty_combined.add_cards(**init_dict_combined,
                                              inplace=True)
        card1c = empty_combined.loc[cid1]
        card2c = empty_combined.loc[cid2]

        self.assertDictEqual(init_dict1, self._cards_dict(card1))
        self.assertDictEqual(init_dict2, self._cards_dict(card2))
        self.assertDictEqual(init_dict1, self._cards_dict(card1c))
        self.assertDictEqual(init_dict2, self._cards_dict(card2c))

        self.assertEqual(len(empty), 2)
        self.assertEqual(len(empty_combined), 2)
Ejemplo n.º 6
0
 def test_dids(self):
     did2s = {"cards": set(self.cards.did), "revs": set(self.revs.did)}
     dids = set(raw.get_did2deck(self.db))
     for table, dids2 in did2s.items():
         with self.subTest(table=table):
             self.assertTrue(dids2.issubset(dids))