Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_create_via_signal(self, client, responses):
signal = Signal()
signal.name = "Test"
signal.country = "NZ"
signal.add_dimension("city", "category")
signal.add_dimension("revenue", "number")
result = signal.save(client.signals)
self.assertIsInstance(result, Signal)
self.assertIsInstance(result, SavedSignal)
self.assertIsNotNone(result.id)
def test_create_via_signal(self, client, responses):
signal = Signal()
signal.name = "Test"
signal.country = "NZ"
signal.add_dimension("city", "category")
signal.add_dimension("revenue", "number")
result = signal.save(client.signals)
self.assertIsInstance(result, Signal)
self.assertIsInstance(result, SavedSignal)
self.assertIsNotNone(result.id)
def test_get(self, client, responses):
result = client.signals.get(id="zVNLr8tHvWQw")
self.assertIsInstance(result, Signal)
self.assertIsInstance(result, SavedSignal)
@accepts(Signal, query_string=False, role="create")
@returns(SavedSignal)
def create(self, **data):
return self.client.post(self.build_url('v1', 'signals'), json=data)
def summary(self):
return self._endpoint.dimensions(id=self.id)
def analysis(self, **params):
return self._endpoint.analysis(id=self.id, **params)
class NewSignal(Signal):
class Options(Signal.Options):
pass
class SavedSignal(SignalID, Signal):
class Options(Signal.Options):
pass
class SignalResultSet(ResultSet):
results = ResultType(SavedSignal)
class DataPoint(Model):
uid = StringType(required=True)
date = DateTimeType(required=True)
latitude = FloatType(min_value=-90, max_value=90, required=True)
longitude = FloatType(min_value=-180, max_value=180, required=True)
initiated = DateTimeType()
completed = DateTimeType()
return self._endpoint.sink(id=self.id, data_points=data_points, chunk_size=chunk_size)
def summary(self):
return self._endpoint.dimensions(id=self.id)
def analysis(self, **params):
return self._endpoint.analysis(id=self.id, **params)
class NewSignal(Signal):
class Options(Signal.Options):
pass
class SavedSignal(SignalID, Signal):
class Options(Signal.Options):
pass
class SignalResultSet(ResultSet):
results = ResultType(SavedSignal)
class DataPoint(Model):
uid = StringType(required=True)
date = DateTimeType(required=True)
latitude = FloatType(min_value=-90, max_value=90, required=True)
longitude = FloatType(min_value=-180, max_value=180, required=True)
return self._endpoint.create(self)
def delete(self):
self._endpoint.delete(id=self.id)
def sink(self, data_points, chunk_size=1000):
return self._endpoint.sink(id=self.id, data_points=data_points, chunk_size=chunk_size)
def summary(self):
return self._endpoint.dimensions(id=self.id)
def analysis(self, **params):
return self._endpoint.analysis(id=self.id, **params)
class NewSignal(Signal):
class Options(Signal.Options):
pass
class SavedSignal(SignalID, Signal):
class Options(Signal.Options):
pass
class SignalResultSet(ResultSet):
results = ResultType(SavedSignal)