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) -> None: """Setup for test case""" self.user = test_utils.create_dummyuser() self.fridge = test_utils.create_dummyfridge("Fridge A") self.fridge_b = test_utils.create_dummyfridge("Fridge B") test_utils.connect_fridge_user(self.user.username, self.fridge.name) test_utils.connect_fridge_user(self.user.username, self.fridge_b.name) self.item_a = test_utils.create_items("Item A") self.item_b = test_utils.create_items("Item B") date = timezone.datetime.now() + timezone.timedelta(days=1) date_future = timezone.datetime.now() + timezone.timedelta(days=10) test_utils.create_fridge_content(self.item_a.item_id, self.fridge.fridge_id, year=date_future.year, month=date_future.month, day=date_future.day) test_utils.create_fridge_content(self.item_b.item_id, self.fridge.fridge_id, year=date.year, month=date.month, day=date.day) test_utils.create_fridge_content(self.item_a.item_id, self.fridge_b.fridge_id, year=date.year, month=date.month, day=date.day)
def test_create_fridge_already_exists(self): """Create a fridge, which already exists. Expecting 409 response""" request = self.factory.post("/fridge/management/create/", { "name": "Fridge A", "description": "Fridge Test" }, content_type="application/json") fridge = test_utils.create_dummyfridge("Fridge A") test_utils.connect_fridge_user("User", fridge.name) request.META["HTTP_AUTHORIZATION"] = "API Token" response = create_fridge.create_fridge_view(request) self.assertEqual(response.status_code, status.HTTP_409_CONFLICT)
def setUp(self) -> None: """Setup for test case""" self.user = test_utils.create_dummyuser() self.user_b = test_utils.create_dummyuser(username="******", email="*****@*****.**") self.fridge = test_utils.create_dummyfridge("Fridge A") test_utils.connect_fridge_user(self.user.username, self.fridge.name) test_utils.connect_fridge_user(self.user_b.username, self.fridge.name) test_utils.create_message_token(tok="fridgify_1", username=self.user.username) test_utils.create_message_token(tok="hopper_1", username=self.user.username, provider="Hopper") test_utils.create_message_token(tok="fridgify_2", username=self.user_b.username)
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"])
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" )
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()