def test_no_args(): """Running del with no args""" testutils.deploy_config(testutils.get_default_config()) rtn = testutils.dtf("prop del") testutils.undeploy() assert (rtn.return_code == 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_set_a_prop(): """Set an arbitrary property""" testutils.deploy_config(testutils.get_default_config()) rtn = testutils.dtf("prop set Info magic AbraKadabra") testutils.undeploy() assert (rtn.return_code == 0)
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_reset_bail(): """Attempt a reset but decline""" testutils.deploy_config(testutils.get_default_config()) rtn = testutils.dtf("reset", input_data="n\n") testutils.undeploy() assert (rtn.return_code == 255)
def test_reset_real(): """Perform a reset""" testutils.deploy_config(testutils.get_default_config()) rtn = testutils.dtf("reset", input_data="y\n") testutils.undeploy() assert (rtn.return_code == 0)
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_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_invalid_prop(): """Get a non-existing property""" testutils.deploy_config(testutils.get_default_config()) rtn = testutils.dtf("prop get Info magic") testutils.undeploy() assert(rtn.return_code == 255)
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_test_invalid_prop(): """Test an invalid property""" testutils.deploy_config(testutils.get_default_config()) rtn = testutils.dtf("prop test Info magic") testutils.undeploy() assert(rtn.return_code == 0)
def test_not_subcommand(): """Call invalid subcommand""" testutils.deploy_config(testutils.get_default_config()) rtn = testutils.dtf("prop NON_EXIST") testutils.undeploy() assert(rtn.return_code == 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_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_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_del_valid_prop(): """Delete a valid property""" config = testutils.get_default_config() config.set("Info", "magic", "AbraKadabra") testutils.deploy_config(config) rtn = testutils.dtf("prop del Info magic") testutils.undeploy() assert (rtn.return_code == 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_no_args(): """Run with not args""" testutils.deploy_config(testutils.get_default_config()) example_local = "%s/example" % utils.LOCAL_MODULES_DIRECTORY utils.touch(example_local) rtn = testutils.dtf("local") testutils.undeploy() assert (rtn.return_code == 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
# """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?") log.LOG_FILE = tmp_log_file # Error Messages