示例#1
0
 def test_single_select_field_multiple_on_save(helpers):
     theRecord = pytest.app.records.create(
         **{"Required Single-select": "a"})
     with pytest.raises(exceptions.ValidationError) as excinfo:
         theRecord["Single-select"] = ["two", "three"]
     assert str(
         excinfo.value
     ) == "Validation failed for <Record: {}>. Reason: Field 'Single-select' expects one of '{}', got 'list' instead".format(
         theRecord.tracking_id, ("str", "basestring")[pytest.py_ver() == 2])
 def test_reporting_filter_similar_field_name(helpers):
     report = pytest.app.reports.build('report-%s' % pytest.fake.word(),
                                       limit=0)
     fieldName = 'texts'
     with pytest.raises(KeyError) as excinfo:
         report.filter(fieldName, 'equals', 'Hello')
     assert str(
         excinfo.value
     ) == '"<App: %s> has no field \'%s\'. Similar fields: %s\'Text\'"' % (
         pytest.app, fieldName, 'u' if (pytest.py_ver() == 2) else '')
示例#3
0
 def test_single_select_field_empty_on_save(helpers):
     theRecord = pytest.app.records.create(
         **{"Required Single-select": "a"})
     with pytest.raises(exceptions.ValidationError) as excinfo:
         theRecord["Single-select"] = ""
     assert str(
         excinfo.value
     ) == 'Validation failed for <Record: {}>. Reason: Field "Single-select" invalid value "". Valid options: {}'.format(
         theRecord.tracking_id, ', '.join(
             pytest.single_select_falues[::(-1, 1)[pytest.py_ver() == 2]]))
示例#4
0
 def test_single_select_field_multiple(helpers):
     with pytest.raises(exceptions.ValidationError) as excinfo:
         pytest.app.records.create(**{
             "Required Single-select": "a",
             "Single-select": ["two", "three"]
         })
     assert str(
         excinfo.value
     ) == "Validation failed for <Record: {} - New>. Reason: Field 'Single-select' expects one of '{}', got 'list' instead".format(
         pytest.app.acronym, ("str", "basestring")[pytest.py_ver() == 2])
示例#5
0
 def test_single_select_field_empty(helpers):
     with pytest.raises(exceptions.ValidationError) as excinfo:
         pytest.app.records.create(**{
             "Required Single-select": "a",
             "Single-select": ""
         })
     assert str(
         excinfo.value
     ) == 'Validation failed for <Record: {} - New>. Reason: Field "Single-select" invalid value "". Valid options: {}'.format(
         pytest.app.acronym, ', '.join(
             pytest.single_select_falues[::(-1, 1)[pytest.py_ver() == 2]]))
示例#6
0
 def test_multi_select_field_select_value_int_on_save(helpers):
     theRecord = pytest.app.records.create(
         **{
             "Required Single-select": "a",
             "Multi-select": ["first", "second"]
         })
     with pytest.raises(exceptions.ValidationError) as excinfo:
         theRecord["Multi-select"].select(2)
     assert str(
         excinfo.value
     ) == "Validation failed for <Record: {}>. Reason: Field 'Multi-select' expects one of '{}', got 'int' instead".format(
         theRecord.tracking_id, ("str", "basestring")[pytest.py_ver() == 2])