Example #1
0
 def test_update_item_tags_to_set(self):
     l = CheatSheet()
     l.add_item(Entry('1', 'c1', 'prim1', tags={'a', 'b'}, oid=1),
                initial_load=True)
     l.update_item(1, tags=['a', 'b'])
     assert l.get_item(1).tags == {'a', 'b'}
     assert not l.modified
Example #2
0
 def test_update_item_bad_id(self):
     l = CheatSheet()
     l.add_item(Entry('orig text 1',
                      'answer1',
                      'prim1',
                      tags={'a', 'b'},
                      oid=1),
                initial_load=True)
     with pytest.raises(base.InvalidIDError):
         l.update_item(6, clue='stuff')
Example #3
0
 def test_update_item_nochange(self):
     l = CheatSheet()
     l.add_item(Entry('c1', 'a1', 'prim1', tags={'a', 'b'}, oid=1),
                initial_load=True)
     l.update_item(1,
                   clue='c1',
                   answer='a1',
                   primary='prim1',
                   tags={'b', 'a'})
     assert not l.modified
     assert l.modified_date == None
Example #4
0
    def test_update_item_clue(self):
        init = [
            Entry('orig text 1', 'answer1', 'prim1', oid=1, tags={'a', 'b'}),
        ]
        l = CheatSheet()
        for i in init:
            l.add_item(i, initial_load=True)

        assert not l.modified
        assert l.get_item(1).answer == 'answer1'
        l.update_item(1, answer='answer new')
        assert l.get_item(1).answer == 'answer new'
        assert l.modified
        assert l.modified_date == MOCK_TIME
Example #5
0
    def test_update_item_clue(self):
        init = [
            Entry('orig text 1', 'answer1', 'prim1', oid=1, tags={'a', 'b'}),
            Entry('orig text 2', 'answer2', 'prim2', oid=2, tags={}),
            Entry('orig text 3', 'answer3', 'prim2', oid=10, tags={'c'}),
        ]
        l = CheatSheet()
        for i in init:
            l.add_item(i, initial_load=True)

        assert not l.modified
        assert l.get_item(1).clue == 'orig text 1'
        l.update_item(1, clue='new text 1')
        assert l.get_item(1).clue == 'new text 1'
        assert l.modified
        assert l.modified_date == MOCK_TIME
Example #6
0
    def test_update_item_tags(self):
        init = [
            Entry('orig text 1', 'answer1', 'prim1', oid=1, tags={'a', 'b'}),
            Entry('orig text 2', 'answer2', 'prim2', oid=2, tags={}),
            Entry('orig text 3', 'answer3', 'prim2', oid=10, tags={'c'}),
        ]
        l = CheatSheet()
        for i in init:
            l.add_item(i, initial_load=True)

        assert l.tag_set == {'prim1', 'prim2', 'a', 'b', 'c'}
        assert l.get_item(1).tags == {'a', 'b'}
        l.update_item(1, tags={'a', 'd'})
        assert l.tag_set == {'prim1', 'prim2', 'a', 'd', 'c'}
        assert l.get_item(1).tags == {'a', 'd'}
        assert l.modified
        assert l.modified_date == MOCK_TIME