def test_remote_json(self, records_json): json_file = os.path.join(conf.DATA_PATH, 'ostriz.json') with io.open(json_file, encoding='utf-8') as input_json: parsed = input_json.read() retval = Mock() retval.text = parsed with patch('requests.get', return_value=retval): loaded_json = ostriztools.import_ostriz('https://foo') assert loaded_json == records_json
def test_no_json(self): with pytest.raises(Dump2PolarionException) as excinfo: ostriztools.import_ostriz('NONEXISTENT.json') assert 'Invalid location' in str(excinfo.value)
def test_invalid_json(self): fname = 'junit-report.xml' with pytest.raises(Dump2PolarionException) as excinfo: ostriztools.import_ostriz(os.path.join(conf.DATA_PATH, fname)) assert 'Failed to parse JSON' in str(excinfo.value)
def test_remote_invalid_json(self): with patch('requests.get', return_value=False): with pytest.raises(Dump2PolarionException) as excinfo: ostriztools.import_ostriz('https://foo') assert 'Failed to parse JSON' in str(excinfo.value)
def records_json_search(): json_file = os.path.join(conf.DATA_PATH, 'ostriz_search.json') return ostriztools.import_ostriz(json_file)