Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #15
0
def test_not_has_key():
    from db_model import Document
    temp = Document()
    assert not temp.has_key('a')
Beispiel #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
Beispiel #17
0
def test_no_added_field():
    from db_model import Document
    temp = Document()
    with pytest.raises(KeyError):
        temp['c']
Beispiel #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)
Beispiel #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')
Beispiel #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')
Beispiel #21
0
def test_not_has_key():
    from db_model import Document
    temp = Document()
    assert not temp.has_key('a')
Beispiel #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')
Beispiel #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')