Ejemplo n.º 1
0
 def test_add_two_cards(self):
     new_map = MathsMap(name="Two to add")
     card1 = new_map.add_card(title="The first card")
     card2 = new_map.add_card(title="The second card")
     self.assertNotEqual(card1.id, card2.id)
     self.assertIn(card1, new_map.flashcards.values())
     self.assertIn(card2, new_map.flashcards.values())
     self.assertEqual(len(new_map.flashcards), 2)
Ejemplo n.º 2
0
 def test_save_and_pickle_map_without_links(self):
     original_map = MathsMap(name="Big Map")
     for i in range(20):
         original_map.add_card(title=str(i), text="This is a great card " + str(i))
     new_map = MathsMap(**loads(dumps(original_map.make_save_dict())))
     self.assertEqual(original_map.name, new_map.name)
     self.assertEqual(len(original_map.flashcards), len(new_map.flashcards))
     for id_,original_card in original_map.flashcards.items():
         new_card = new_map.flashcards[id_]
         for key in ["title", "text", "id"]:
             self.assertEqual(getattr(new_card, key), getattr(original_card, key))
Ejemplo n.º 3
0
 def test_mathsmaps_do_not_interfere(self):
     mathsmap1 = MathsMap(name="Map1")
     mathsmap2 = MathsMap(name="Map2")
     card = mathsmap1.add_card()
     self.assertIn(card, mathsmap1.flashcards.values())
     self.assertNotIn(card, mathsmap2.flashcards.values())
     self.assertEqual(len(mathsmap2.flashcards), 0)
Ejemplo n.º 4
0
 def test_add_card_to_map_with_cards(self):
     id1, id2 = uuid4(), uuid4()
     new_map = MathsMap(name="Only one for now", flashcard_dicts={id1:dict(title="The first card")})
     self.assertEqual(len(new_map.flashcards), 1)
     card = new_map.add_card(id_=id2, title="The second card")
     self.assertEqual(len(new_map.flashcards), 2)
     self.assertEqual(card, new_map.flashcards[id2])
Ejemplo n.º 5
0
 def test_add_card_without_id(self):
     new_map = MathsMap(name="Empty")
     card = new_map.add_card(title="A new card!", text="This card is new")
     self.assertIsInstance(card.id, UUID)
     self.assertEqual(card.title, "A new card!")
     self.assertEqual(card.text, "This card is new")
     self.assertEqual(len(new_map.flashcards), 1)
     self.assertIn(card, new_map.flashcards.values())
     self.assertEqual(new_map.flashcards[card.id], card)
Ejemplo n.º 6
0
 def test_save_and_pickle_links(self):
     original_map = MathsMap(name="Two cards")
     card1 = original_map.add_card(title="CARD1")
     card2 = original_map.add_card(title="CARD2")
     original_map.add_link(card1, card2)
     new_map = MathsMap(**loads(dumps(original_map.make_save_dict())))
     new_card1, new_card2 = new_map.flashcards[card1.id], new_map.flashcards[card2.id]
     self.assertTrue(is_linked(new_card1, new_card2))
     self.assertTrue(is_not_linked(new_card2, new_card1))
Ejemplo n.º 7
0
 def test_add_card_with_id(self):
     new_map = MathsMap(name="Empty")
     id_ = uuid4()
     card = new_map.add_card(id_=id_)
     self.assertEqual(id_, card.id)
     self.assertEqual(new_map.flashcards[id_], card)