def setUp(self) -> None:
        """Setup for test case"""
        self.factory = RequestFactory()
        test_utils.setup()
        self.user = test_utils.create_dummyuser()
        self.user2 = test_utils.create_dummyuser(username="******",
                                                 email="*****@*****.**")
        self.fridge = test_utils.create_dummyfridge()
        test_utils.connect_fridge_user()
        test_utils.create_login_token(timezone.now() +
                                      timezone.timedelta(days=1),
                                      username=self.user.username)
        test_utils.create_api_token(timezone.now() +
                                    timezone.timedelta(days=1),
                                    tok="API Token",
                                    username=self.user2.username)
        test_utils.create_api_token(timezone.now() +
                                    timezone.timedelta(days=1),
                                    tok="Already in Fridge",
                                    username=self.user.username)

        self.token = "jointoken"
        test_utils.create_join_token(tok=self.token, fridge=self.fridge)
        self.s_request = self.factory.get(
            f"/fridge/management/join?token={self.token}")
        self.s_request.META["HTTP_AUTHORIZATION"] = "API Token"
 def setUp(self):
     """Setup for test case"""
     test_utils.setup()
     self.factory = RequestFactory()
     self.user = Users.objects.create(
         username="******",
         name="Dummy",
         surname="Name",
         email="*****@*****.**",
         password=
         "******",
         birth_date=datetime.date(2000, 1, 1))
     self.user2 = Users.objects.create(
         username="******",
         name="Test",
         surname="User",
         email="*****@*****.**",
         password=
         "******",
         birth_date=datetime.date(2000, 1, 1))
     fridge = Fridges.objects.create(name="Miau", description="adsdsadad")
     fill_fridges([fridge])
     fridge2 = Fridges.objects.create(name="Wuff", description="adsdsadad")
     UserFridge.objects.create(fridge_id=fridge.fridge_id,
                               user_id=self.user.user_id)
     UserFridge.objects.create(fridge_id=fridge2.fridge_id,
                               user_id=self.user2.user_id)
Example #3
0
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     test_utils.create_dummyuser()
     test_utils.create_items("Item A")
     test_utils.create_items("Item B")
     test_utils.create_api_token(timezone.now() +
                                 timezone.timedelta(hours=1))
Example #4
0
 def setUp(self):
     """Setup for test"""
     self.factory = RequestFactory()
     test_utils.setup()
     test_utils.create_dummyuser()
     Accesstokens.objects.create(
         accesstoken="Token",
         provider=Providers.objects.filter(name="Fridgify").first(),
         valid_till=timezone.now() + datetime.timedelta(days=14),
         user=Users.objects.filter(username="******").first())
Example #5
0
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.clean()
     test_utils.setup()
     user = test_utils.create_dummyuser()
     Accesstokens.objects.create(
         user=user,
         accesstoken="Token",
         provider=Providers.objects.get(name="Fridgify"),
         valid_till=timezone.now() + timezone.timedelta(days=1))
Example #6
0
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     user = test_utils.create_dummyuser(username="******")
     test_utils.create_login_token(timezone.now() +
                                   timezone.timedelta(days=1),
                                   username=user.username)
     test_utils.create_api_token(timezone.now() +
                                 timezone.timedelta(days=1),
                                 tok="API Token",
                                 username=user.username)
Example #7
0
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     test_utils.create_dummyuser()
     test_utils.create_dummyfridge()
     test_utils.connect_fridge_user()
     test_utils.create_login_token(timezone.now() +
                                   timezone.timedelta(days=14))
     test_utils.create_api_token(timezone.now() +
                                 timezone.timedelta(days=14))
     test_utils.create_items("Item A")
     test_utils.create_items("Item B")
     test_utils.create_fridge_content(
         test_utils.get_item("Item A").values()[0]["item_id"],
         test_utils.get_fridge("Dummy Fridge").values()[0]["fridge_id"])
Example #8
0
 def setUp(self) -> None:
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     self.user = test_utils.create_dummyuser()
     self.fridge = test_utils.create_dummyfridge()
     test_utils.connect_fridge_user()
     test_utils.create_login_token(
         timezone.now() + timezone.timedelta(days=1),
         username=self.user.username
     )
     test_utils.create_api_token(
         timezone.now() + timezone.timedelta(days=1),
         tok="API Token",
         username=self.user.username
     )
     self.s_request = self.factory.get(f"/fridge/management/{self.fridge.fridge_id}/qr-code")
     self.s_request.META["HTTP_AUTHORIZATION"] = "API Token"
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     test_utils.create_dummyuser()
     test_utils.create_dummyuser("us2", "user", "name", "[email protected]")
     test_utils.create_dummyfridge()
     test_utils.connect_fridge_user()
     test_utils.create_items("Item A")
     test_utils.create_items("Item B")
     test_utils.create_login_token(
         timezone.now() + timezone.timedelta(hours=1)
     )
     test_utils.create_api_token(
         timezone.now() + timezone.timedelta(hours=1)
     )
     test_utils.create_api_token(
         timezone.now() + timezone.timedelta(hours=1),
         username="******",
         tok="APIToken2"
     )
Example #10
0
    def setUp(self):
        """Setup for test case"""
        self.factory = RequestFactory()
        test_utils.setup()
        self.user = []
        self.user.append(test_utils.create_dummyuser(
            username="******",
            name="Test",
            surname="User",
            email="*****@*****.**"
        ))
        self.user.append(test_utils.create_dummyuser(
            username="******",
            name="Test 2",
            surname="User 2",
            email="*****@*****.**"
        ))
        self.user.append(test_utils.create_dummyuser(
            username="******",
            name="Test 3",
            surname="User 3",
            email="*****@*****.**"
        ))
        self.fridge = test_utils.create_dummyfridge(name="Test Fridge")

        test_utils.connect_fridge_user(
            username=self.user[0].username,
            fridge=self.fridge.name,
            role=const.Constants.ROLE_OWNER
        )
        test_utils.connect_fridge_user(
            username=self.user[1].username,
            fridge=self.fridge.name,
            role=const.Constants.ROLE_OVERSEER
        )
        test_utils.connect_fridge_user(
            username=self.user[2].username,
            fridge=self.fridge.name,
            role=const.Constants.ROLE_USER
        )

        test_utils.create_login_token(
            timezone.now() + timezone.timedelta(days=1),
            username=self.user[0].username
        )
        test_utils.create_api_token(
            timezone.now() + timezone.timedelta(days=1),
            tok="API Token User1",
            username=self.user[0].username
        )

        test_utils.create_login_token(
            timezone.now() + timezone.timedelta(days=1),
            username=self.user[1].username
        )
        test_utils.create_api_token(
            timezone.now() + timezone.timedelta(days=1),
            tok="API Token User2",
            username=self.user[1].username
        )

        test_utils.create_login_token(
            timezone.now() + timezone.timedelta(days=1),
            username=self.user[2].username
        )
        test_utils.create_api_token(
            timezone.now() + timezone.timedelta(days=1),
            tok="API Token User3",
            username=self.user[2].username
        )
        return super().setUp()