Esempio n. 1
0
 def test_missing_type(self):
     from db_model import Document, ModelError
     temp = Document(name='Name',
                     year=2015,
                     participants=['Stan', 'Pierre'])
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 2
0
 def test_competition_missing_field(self):
     from db_model import Document, ModelError
     temp = Document('competition',
                     name='Name',
                     participants=['Stan', 'Pierre'])
     with pytest.raises(ModelError):
         data = temp.save(safe_input=True)
Esempio n. 3
0
 def test_competition_unsafe(self):
     from db_model import Document
     temp = Document('competition',
                     name='Name',
                     participants=['Stan', 'Pierre'])
     temp.save(safe_input=False)
     assert True
Esempio n. 4
0
 def test_embedded_doc_ok(self):
     from db_model import Document, ModelError
     import datetime
     temp = Document('match', team_A='a', team_B='b', home='b',  date=datetime.datetime.now(),
                     competition = 'c', day=1,
                     result=Document('result', team_A_goals=1, team_B_goals=2),
                     pronos=[Document('prono', participant_name='a', team_A_goals=1, team_B_goals=1)])
     temp.save(safe_input=True)
Esempio n. 5
0
 def test_competition_wrong_type(self):
     from db_model import Document, ModelError
     temp = Document('competition',
                     name='Name',
                     year=2015,
                     participants='Stan')
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 6
0
 def test_safe_competition(self):
     from db_model import Document
     temp = Document('competition',
                     name='Name',
                     year=2015,
                     participants=['Stan', 'Pierre'])
     temp.save(safe_input=True)
     assert True
Esempio n. 7
0
 def test_inlist_type(self):
     from db_model import Document, ModelError
     temp = Document('competition',
                     name='Name',
                     year='2015',
                     participants=['Stan', 12])
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 8
0
 def test_wrong_field(self):
     from db_model import Document, ModelError
     temp = Document('competition',
                     name='Name',
                     year=2015,
                     participants=['Stan', 'Pierre'],
                     wrong_one='unexpected')
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 9
0
 def test_embedded_doc_error(self):
     from db_model import Document, ModelError
     import datetime
     temp = Document('match',
                     teamA='a',
                     teamB='b',
                     home='b',
                     date=datetime.datetime.now(),
                     competition='c',
                     day=1,
                     result=Document(team_A_goals=1, team_B_goals=2),
                     pronos=[
                         Document('prono',
                                  participant_name='a',
                                  team_A_goals=1,
                                  team_B_goals=1)
                     ])
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 10
0
 def test_competition_unsafe(self):
     from db_model import Document
     temp = Document('competition', name='Name', participants=['Stan', 'Pierre'])
     temp.save(safe_input=False)
     assert True
Esempio n. 11
0
 def test_wrong_field(self):
     from db_model import Document, ModelError
     temp = Document('competition', name='Name', year=2015, participants=['Stan', 'Pierre'], wrong_one='unexpected')
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 12
0
 def test_competition_wrong_type(self):
     from db_model import Document, ModelError
     temp = Document('competition', name='Name', year=2015, participants='Stan')
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 13
0
 def test_missing_type(self):
     from db_model import Document, ModelError
     temp = Document(name='Name', year=2015, participants=['Stan', 'Pierre'])
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 14
0
 def test_competition_missing_field(self):
     from db_model import Document, ModelError
     temp = Document('competition', name='Name', participants=['Stan', 'Pierre'])
     with pytest.raises(ModelError):
         data = temp.save(safe_input=True)
Esempio n. 15
0
def test_not_has_key():
    from db_model import Document
    temp = Document()
    assert not temp.has_key('a')
Esempio n. 16
0
 def test_safe_competition(self):
     from db_model import Document
     temp = Document('competition', name='Name', year=2015, participants=['Stan', 'Pierre'])
     temp.save(safe_input=True)
     assert True
Esempio n. 17
0
def test_no_added_field():
    from db_model import Document
    temp = Document()
    with pytest.raises(KeyError):
        temp['c']
Esempio n. 18
0
 def test_inlist_type(self):
     from db_model import Document, ModelError
     temp = Document('competition', name='Name', year='2015', participants=['Stan', 12])
     with pytest.raises(ModelError):
         temp.save(safe_input=True)
Esempio n. 19
0
def test_has_key():
    from db_model import Document
    temp = Document(a=12)
    temp['c'] = 'string'
    assert temp.has_key('a') and temp.has_key('c')
Esempio n. 20
0
def test_new_field():
    from db_model import Document
    temp = Document(a=12)
    temp['c'] = 'string'
    assert (temp['a'] == 12) and (temp['c'] == 'string')
Esempio n. 21
0
def test_not_has_key():
    from db_model import Document
    temp = Document()
    assert not temp.has_key('a')
Esempio n. 22
0
def test_has_key():
    from db_model import Document
    temp = Document(a=12)
    temp['c'] = 'string'
    assert temp.has_key('a') and temp.has_key('c')
Esempio n. 23
0
def test_document_init():
    from db_model import Document
    temp = Document(a=12, c='string')
    assert (temp['a'] == 12) and (temp['c'] == 'string')