def test_register(self): """Test registration of devices.""" response = self.client.post( reverse(self.REGISTER_DEVICE_URL), Dummy.device_register_data() ) self.assertTrue("token" in response.data) self.assertTrue("uuid" in response.data) self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_create_ambiguous_time_board_date(self): """Test registration with ambiguous time. Test the resolution of a naive date-time in which the Europe/Amsterdam daylight saving time transition moved the time "backward". The server should not crash when receiving a naive date-time that can belong to multiple timezones. """ data = Dummy.device_register_data() # In 2017, the Netherlands changed from CEST to CET on October, # 29 at 03:00 data["board_date"] = "2017-10-29 02:34:56" response = self.client.post(reverse(self.REGISTER_DEVICE_URL), data) self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_create_non_existent_time_board_date(self): """Test registration with non existing time. Test the resolution of a naive date-time in which the Europe/Amsterdam daylight saving time transition moved the time "forward". The server should not crash when receiving a naive date-time which does not exist in the server timezone or locale. """ data = Dummy.device_register_data() # In 2017, the Netherlands changed from CET to CEST on March, # 26 at 02:00 data["board_date"] = "2017-03-26 02:34:56" response = self.client.post(reverse(self.REGISTER_DEVICE_URL), data) self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_create_invalid_board_date(self): """Test registration with invalid board date.""" data = Dummy.device_register_data() data["board_date"] = "not_a_valid_date" response = self.client.post(reverse(self.REGISTER_DEVICE_URL), data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_create_missing_chipset(self): """Test registration with missing chipset.""" data = Dummy.device_register_data() data.pop("chipset") response = self.client.post(reverse(self.REGISTER_DEVICE_URL), data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)