def test_cache(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 Scalar(name, value) scalar_2 = Scalar(name, value) assert scalar_2.get_value() == value assert scalar_2.get_name() == name
def test_any_case(add_response): name, value = 'telemetry.test.UNSIGNED_int_kind', 8 Scalar(name, value) scalar_2 = Scalar(name, value) assert scalar_2.get_value() == value assert scalar_2.get_name() == name
def test_release_url(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value, scalars_url=release_file) assert scalar.get_value() == value assert scalar.get_name() == name
def test_string_scalar(add_response): name, value = 'telemetry.test.string_kind', 'string' scalar = Scalar(name, value) assert scalar.get_value() == value assert scalar.get_name() == name assert scalar.get_kind() == 'string'
def test_boolean_scalar(add_response): name, value = 'telemetry.test.boolean_kind', True scalar = Scalar(name, value) assert scalar.get_value() == value assert scalar.get_name() == name assert scalar.get_kind() == 'boolean'
def test_release_revision(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value, revision='https://hg.mozilla.org/releases/mozilla-release/rev/tip') assert scalar.get_value() == value assert scalar.get_name() == name
def test_release_channel(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value, channel='release') assert scalar.get_value() == value assert scalar.get_name() == name assert Scalar.REQUIRED_FIELDS.issubset(scalar.get_definition().viewkeys())
def test_int_scalar(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value) assert scalar.get_value() == value assert scalar.get_name() == name assert scalar.get_kind() == 'uint'
def test_release_revision(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value, revision='https://hg.mozilla.org/releases/mozilla-release/rev/tip') assert scalar.get_value() == value assert scalar.get_name() == name assert Scalar.REQUIRED_FIELDS.issubset(scalar.get_definition().viewkeys())
def test_release_revision(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar( name, value, revision='https://hg.mozilla.org/releases/mozilla-release/rev/tip') assert scalar.get_value() == value assert scalar.get_name() == name
def test_channel_and_revision(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 with pytest.raises(ValueError): Scalar( name, value, channel='nightly', revision='https://hg.mozilla.org/releases/mozilla-release/rev/tip')
def test_int_addition(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value) + Scalar(name, value) assert scalar.get_value() == value * 2 assert scalar.get_name() == name assert Scalar.REQUIRED_FIELDS.issubset(scalar.get_definition().viewkeys())
def test_boolean_scalar(add_response): name, value = 'telemetry.test.boolean_kind', True scalar = Scalar(name, value) assert scalar.get_value() == value assert scalar.get_name() == name assert scalar.get_definition().get('kind') == 'boolean' assert Scalar.REQUIRED_FIELDS.issubset(scalar.get_definition().viewkeys())
def test_string_scalar(add_response): name, value = 'telemetry.test.string_kind', 'string' scalar = Scalar(name, value) assert scalar.get_value() == value assert scalar.get_name() == name assert scalar.get_definition().get('kind') == 'string' assert Scalar.REQUIRED_FIELDS.issubset(scalar.get_definition().viewkeys())
def test_any_case(add_response): name, value = 'telemetry.test.UNSIGNED_int_kind', 8 Scalar(name, value) scalar_2 = Scalar(name, value) assert scalar_2.get_value() == value assert scalar_2.get_name() == name assert Scalar.REQUIRED_FIELDS.issubset( scalar_2.get_definition().viewkeys())
def test_int_addition(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value) + Scalar(name, value) assert scalar.get_value() == value * 2 assert scalar.get_name() == name
def test_boolean_addition(add_response): name, value = 'telemetry.test.boolean_kind', True with pytest.raises(AttributeError): Scalar(name, value) + Scalar(name, value)
def test_string_addition(add_response): name, value = 'telemetry.test.string_kind', 'string' with pytest.raises(AttributeError): Scalar(name, value) + Scalar(name, value)
def _get_description(channel, prefix, metric): if prefix != NUMERIC_SCALARS_PREFIX: return '' metric = metric.replace(prefix + '_', '').lower() return Scalar(metric, 0, channel=channel).definition.description
def test_release_channel(add_response): name, value = 'telemetry.test.unsigned_int_kind', 8 scalar = Scalar(name, value, channel='release') assert scalar.get_value() == value assert scalar.get_name() == name
def test_missing_scalar_error(add_response): name, value = 'telemetry.test.missing_kind', 8 with pytest.raises(MissingScalarError): Scalar(name, value)