def test_createFromResponse(self): mockResponse = readJson('response/error_502.json') error = PyViCareCommandError(mockResponse) self.assertEqual( error.message, 'Command failed with status code 502. Reason given was: INTERNAL_SERVER_ERROR')
def __init__(self, filename, circuit, rawInput=None): if rawInput is None: testData = readJson(filename) self.testData = testData else: self.testData = rawInput self.circuit = circuit self.setPropertyData = []
def test_createFromResponse(self): mockResponse = readJson('response/rate_limit.json') error = PyViCareRateLimitError(mockResponse) self.assertEqual( error.message, 'API rate limit ViCare day limit exceeded. Max 1450 calls in timewindow. Limit reset at 2020-03-17T16:20:10.106000.') self.assertEqual(error.limitResetDate, datetime.datetime( 2020, 3, 17, 16, 20, 10, 106000))
def __init__(self, filename, rawInput=None): if rawInput is None: testData = readJson(filename) self.testData = testData else: self.testData = rawInput self.accessor = ViCareDeviceAccessor( '[id]', '[serial]', '[deviceid]') self.setPropertyData = []
def read_all_features(self): response_path = join(dirname(__file__), './response') response_files = [ f for f in listdir(response_path) if isfile(join(response_path, f)) ] all_features = {} for response in response_files: data = readJson(join(response_path, response)) if "data" in data: for feature in data["data"]: name = re.sub(r"\b\d\b", "0", feature["feature"]) if name not in all_features: all_features[name] = {'files': []} if feature['isEnabled'] and feature[ 'properties'] != {} and feature[ 'components'] == []: all_features[name]['files'].append(response) return all_features
def json(self): return readJson(self.file_name)