def test_del_empty_config(): """Attempts to delete a property without a valid config""" testutils.deploy_config_raw("") assert prop.del_prop('info', 'sdk') != 0 testutils.undeploy() return 0
def test_test_empty_config(): """Test a property without a valid config""" testutils.deploy_config_raw("") assert prop.test_prop('info', 'sdk') == 0 testutils.undeploy() return 0
def test_python_precheck_sdk_missing(): """Attempt to run python module with missing SDK""" testutils.deploy_config_raw("") rtn = testutils.dtf("archive") testutils.undeploy() assert(rtn.return_code == 248)
def test_python_load_imp_exception(): """Attempt to run builtin and fail to parse load_imp""" testutils.deploy_config_raw("") rtn = testutils.dtf("status") testutils.undeploy() assert(rtn.return_code == 247)
def test_get_empty_config(): """Attempts to get a property without a valid config""" testutils.deploy_config_raw("") with pytest.raises(prop.PropertyError): prop.get_prop('info', 'sdk') testutils.undeploy() return 0
def test_set_new_section_property(): """Set a property that has no section (yet)""" value = '1' testutils.deploy_config_raw("") prop.set_prop('info', 'sdk', value) assert prop.get_prop('info', 'sdk') == value testutils.undeploy() return 0
def test_set_new_property(): """Attempt to set a new property (existing section)""" value = '1' contents = ("[info]\n" "real = not_real") testutils.deploy_config_raw(contents) prop.set_prop('info', 'sdk', value) assert prop.get_prop('info', 'sdk') == value testutils.undeploy()
def test_test_invalid_property(): """Test a missingproperty""" contents = ("[Info]\n" "vmtype = arm64") testutils.deploy_config_raw(contents) assert prop.test_prop('info', 'sdk') == 0 testutils.undeploy() return 0
def test_test_property(): """Test a valid property""" contents = ("[Info]\n" "sdk = 23") testutils.deploy_config_raw(contents) assert prop.test_prop('info', 'sdk') == 1 testutils.undeploy() return 0
def test_del_property_invalid(): """Attempts to delete a property that doesnt exist""" contents = ("[Info]\n" "vmtype = 64") testutils.deploy_config_raw(contents) assert prop.del_prop('info', 'sdk') != 0 testutils.undeploy() return 0
def test_del_property(): """Attempts to delete a valid property""" contents = ("[Info]\n" "sdk = 23") testutils.deploy_config_raw(contents) prop.del_prop('info', 'sdk') testutils.undeploy() return 0
def test_get_property_no_option(): """Attempt to get property that doesnt exist""" contents = ("[Info]\n" "vmtype = arm64") testutils.deploy_config_raw(contents) with pytest.raises(prop.PropertyError): prop.get_prop('info', 'sdk') testutils.undeploy() return 0
def test_del_property_casing(): """Delete a prop with alternating casing""" sdk = '23' contents = ("[Info]\n" "sdk = %s" % sdk) testutils.deploy_config_raw(contents) prop.del_prop('info', 'sdk') testutils.undeploy() return 0
def test_test_property_casing(): """Test a prop with alternating casing""" sdk = '23' contents = ("[Info]\n" "sdk = %s" % sdk) testutils.deploy_config_raw(contents) assert prop.test_prop('info', 'sdk') == 1 testutils.undeploy() return 0
def test_get_property(): """Attempts to get a valid property""" sdk = '23' contents = ("[Info]\n" "sdk = %s" % sdk) testutils.deploy_config_raw(contents) assert prop.get_prop('info', 'sdk') == sdk testutils.undeploy() return 0
def test_set_property_casing(): """Set a prop and try to retrieve with casing""" sdk = '1' testutils.deploy_config_raw("") prop.set_prop('INFO', 'sdk', sdk) assert prop.get_prop('info', 'sdk') == sdk assert prop.get_prop('Info', 'sdk') == sdk assert prop.get_prop('INFO', 'sdk') == sdk testutils.undeploy() return 0
def test_set_existing_property(): """Set a property that already exists""" value = 'new' contents = ("[Info]\n" "sdk = old") testutils.deploy_config_raw(contents) prop.set_prop('info', 'sdk', value) assert prop.get_prop('info', 'sdk') == value testutils.undeploy() return 0
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """pytest for using dtf logging""" from __future__ import absolute_import import dtf.testutils as testutils import pytest TAG = 'test_log' # We actually need a log file to exist to populate TOP testutils.deploy_config_raw("") import dtf.logging as log # We can undeploy imediately after testutils.undeploy() # General Tests def test_no_config(): """Try to log without a config""" tmp_log_file = log.LOG_FILE log.LOG_FILE = None log.e(TAG, "Will this work?")