Exemple #1
0
 def test_flatten(self):
     d = Data()
     t = Transform(d.object)
     f = t.flatten(t.d)
     for k, v in f.items():
         with pytest.raises(AssertionError):
             assert isinstance(v, dict)
Exemple #2
0
 def test_time_index_length(self):
     this_year = dt.now().year
     this_month = dt.now().month
     this_date = dt.now().day
     d = Data()
     t = Transform(json.loads(d.get_object()))
     r = t.create_time_index()
     assert r[:4] == str(this_year)
     assert r[4:6] == str(this_month)
     assert r[6:8] == str(this_date)
Exemple #3
0
 def test_positive_class_format(self):
     d = Data()
     assert isinstance(d.temp, int)
     assert re.search(
         "([0-z]{8})-([0-z]{4})-([0-z]{4})-([0-z]{4})-([0-z]{12})", d.id)
     assert d.temp >= 80 or d.temp <= 100
     assert d.type == "Sensor"
     assert isinstance(uuid.UUID(d.id), uuid.UUID)
     assert isinstance(datetime.datetime.fromisoformat(d.time),
                       datetime.datetime)
     assert isinstance(d.object, dict)
Exemple #4
0
 def test_init(self):
     d = Data()
     assert isinstance(d.object, dict)
Exemple #5
0
 def test_time_index_format(self):
     d = Data()
     t = Transform(json.loads(d.get_object()))
     assert re.search("([0-9]{14})", t.create_time_index())
Exemple #6
0
 def test_time_index(self):
     d = Data()
     print(d)
     t = Transform(json.loads(d.get_object()))
     assert isinstance(t.d.get('content'), dict)
     assert isinstance(t.create_time_index(), str)
Exemple #7
0
 def test_flatten_content(self):
     d = Data()
     t = Transform(json.loads(d.get_object()))
     f = t.flatten(t.d)
     with pytest.raises(KeyError):
         f['content']
Exemple #8
0
 def test_negative_id(self):
     d = Data()
     d.id = 1
     with pytest.raises(AttributeError):
         assert isinstance(uuid.UUID(d.id), uuid.UUID)
Exemple #9
0
 def test_get_object(self):
     d = Data()
     assert isinstance(d.get_object(), str)
Exemple #10
0
 def test_change_temp(self, fahrenheit, celsius):
     d = Data()
     w = Worker(d.get_object())
     assert w.fahrenheit_to_celsius(fahrenheit) == celsius
Exemple #11
0
 def test_add_t_works(self):
     d = Data()
     w = Worker(d.get_object())
     w.add_t()
     assert isinstance(w.data.get('content').get('temperature_c'), float)
Exemple #12
0
 def test_add_t_len(self):
     d = Data()
     w = Worker(d.get_object())
     w.add_t()
     assert len(w.data.get('content')) == 3
Exemple #13
0
 def test_add_t_content(self):
     d = Data()
     w = Worker(d.get_object())
     assert isinstance(w.data.get('content'), dict)
Exemple #14
0
 def test_worker_format(self):
     d = Data()
     w = Worker(d.get_object())
     assert isinstance(w.data, dict)