def test_get_ref_data_invalid(ptm): """Test get_ref_data method with an invalid key.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) with pytest.raises(FieldError) as e: perftest_refdata.get_ref_data(ptm.project, "not a valid table name") exp = ("FieldError: Not a supported ref_data table. Must be in: " "['tests', 'pages', 'products', 'operating_systems', " "'options', 'machines']") assert e.exconly() == exp
def test_get_ref_data_operating_systems(ptm): """Test get_ref_data method to get operating systems list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "operating_systems") exp = {1: {'id': 1, 'name': 'linux', 'version': 'Ubuntu 11.10'}} assert exp == ref_data
def test_get_ref_data_pages(ptm): """Test get_ref_data method to get pages list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "pages") exp = {'one.com': {'id': 2L, 'test_id': 1L, 'url': 'one.com'}, 'three.com': {'id': 1L, 'test_id': 1L, 'url': 'three.com'}, 'two.com': {'id': 3L, 'test_id': 1L, 'url': 'two.com'}}
def test_get_ref_data_tests(ptm): """Test get_ref_data method to get tests list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "tests") exp = {'Talos tp5r': {'id': 1L, 'name': 'Talos tp5r', 'version': 1L}} assert exp == ref_data
def test_get_ref_data_pages(ptm): """Test get_ref_data method to get pages list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "pages") exp = {'three.com': {'url': 'three.com', 'id': 1L, 'test_ids': {1L: True}}, 'one.com': {'url': 'one.com', 'id': 2L, 'test_ids': {1L: True}}, 'two.com': {'url': 'two.com', 'id': 3L, 'test_ids': {1L: True}}}
def test_get_ref_data_machines(ptm): """Test get_ref_data method to get machines list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "machines") for item in ref_data.itervalues(): del(item["id"]) exp = {'qm-pxp01': {'name': 'qm-pxp01'}} assert exp == ref_data
def test_get_ref_data_machines(ptm): """Test get_ref_data method to get machines list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "machines") for item in ref_data.itervalues(): del(item["id"]) exp = {'qm-pxp01': {'name': 'qm-pxp01'}} assert exp['qm-pxp01']['name'] == ref_data['qm-pxp01']['name']
def test_get_ref_data_products(ptm): """Test get_ref_data method to get products list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "products") exp = { 1:{'branch': 'Mozilla-Aurora', 'default_product': 0, 'id': 1, 'product': 'Firefox', 'version': '14.0a2'} } assert exp == ref_data
def test_get_ref_data_options(ptm): """Test get_ref_data method to get options list.""" ptm.store_test_data(perftest_json()) ptm.process_objects(1) ref_data = perftest_refdata.get_ref_data(ptm.project, "options") exp = {'responsiveness': {'id': 1L, 'name': 'responsiveness'}, 'rss': {'id': 9L, 'name': 'rss'}, 'shutdown': {'id': 8L, 'name': 'shutdown'}, 'tpchrome': {'id': 4L, 'name': 'tpchrome'}, 'tpcycles': {'id': 6L, 'name': 'tpcycles'}, 'tpdelay': {'id': 3L, 'name': 'tpdelay'}, 'tpmozafterpaint': {'id': 2L, 'name': 'tpmozafterpaint'}, 'tppagecycles': {'id': 5L, 'name': 'tppagecycles'}, 'tprender': {'id': 7L, 'name': 'tprender'}}
def get_ref_data(request, project, table): """Get simple list of ref_data for ``table`` in ``project``""" stats = perftest_refdata.get_ref_data(project, table) return HttpResponse(json.dumps(stats), content_type=API_CONTENT_TYPE)