Ejemplo n.º 1
0
    def test_get_by_id(self):
        """Get key by ID."""
        application = Application(name=fake.word(),
                                  support_message=fake.sentence()).save()
        num_days = "15"
        key = Key(token=fake.word(),
                  remaining=randint(-1, 50),
                  app_id=application.id,
                  enabled=True,
                  memo=fake.sentence(),
                  hwid=fake.mac_address(),
                  expiry_date=("%s" % num_days)).save()

        retrieved = Key.get_by_id(key.id)
        assert retrieved == key
        retrieved = Key.get_by_uuid(key.uuid)
        assert retrieved == key
Ejemplo n.º 2
0
    def test_get_by_id(self):
        """Get application by ID."""
        application = Application(name=fake.word(),
                                  support_message=fake.sentence()).save()

        retrieved = Application.get_by_id(application.id)
        assert retrieved == application
        retrieved = Application.get_by_uuid(application.uuid)
        assert retrieved == application
Ejemplo n.º 3
0
 def test_update_title(self, album_list_url, data_for_send, album_dict):
     """
     Проверяем, что title успешно обновился
     :param album_list_url:
     :param album_dict:
     :return:
     """
     response = self.make_request(album_list_url, data_for_send, 'title',
                                  fake.sentence())
     assert response.status_code == 200
Ejemplo n.º 4
0
 def test_application_through_key(self):
     """test the relationship of key.app"""
     application = Application(name=fake.word(),
                               support_message=fake.sentence()).save()
     num_days = "15"
     key1 = Key(token=fake.word(),
                remaining=randint(-1, 50),
                app_id=application.id,
                enabled=True,
                memo=fake.sentence(),
                hwid=fake.mac_address(),
                expiry_date="15").save()
     key2 = Key(token=fake.word(),
                remaining=randint(-1, 50),
                app_id=application.id,
                enabled=True,
                memo=fake.sentence(),
                hwid=fake.mac_address(),
                expiry_date="2020-12-25").save()
     assert key1.app == key2.app == application
Ejemplo n.º 5
0
 def test_update_value_title(self, album_list_url, data_for_send,
                             album_dict):
     """
     Сравниваем с действительным значением в базе
     :param album_list_url:
     :param album_dict:
     :return:
     """
     test_value = fake.sentence()
     response = self.make_request(album_list_url, data_for_send, 'title',
                                  test_value)
     assert response.json()['title'] == test_value
def _register_user(testapp, **kwargs):
    return testapp.post_json(
        url_for("user.register_user"), {
            "user": {
                "username": "******",
                "email": "*****@*****.**",
                "password": "******",
                "bio": fake.sentence(),
                "first_name": "Mo",
                "last_name": "Om",
                "image": fake.url()
            }
        }, **kwargs)
Ejemplo n.º 7
0
    def test_key_expiry_date(self):
        """test that a key is only valid for a period of time"""
        application = Application(name=fake.word(),
                                  support_message=fake.sentence()).save()
        num_days = "15"
        key1 = Key(token=fake.word(),
                   remaining=randint(-1, 50),
                   app_id=application.id,
                   enabled=True,
                   memo=fake.sentence(),
                   hwid=fake.mac_address(),
                   expiry_date=("%s" % num_days)).save()
        key2 = Key(token=fake.word(),
                   remaining=randint(-1, 50),
                   app_id=application.id,
                   enabled=True,
                   memo=fake.sentence(),
                   hwid=fake.mac_address(),
                   expiry_date="2020-12-25").save()

        assert key1.valid_until <= dt.datetime.utcnow() + dt.timedelta(
            days=int(num_days))
        assert key2.valid_until == dt.datetime.combine(dt.date(2020, 12, 25),
                                                       dt.datetime.min.time())