def test_invalid_deletion1(self): dummy_user_1 = User.objects.create_user(username="******", password="******") dummy_user_2 = User.objects.create_user(username="******", password="******") data = desc_utils.DescriptorDataCandidate( desc_utils.DescriptorDataCandidateLocalRawContainer( tools.VALID_SUCC_DESC_C.encode()), user=dummy_user_1) data.submit() desc = db.Descriptor.objects.all() assert len(desc) == 1 client = Client() response = client.login(username="******", password="******") response = client.get("/delete/", { "id": "1", "type": str(DELETE_TYPE_DESCRIPTOR) }) desc = db.Descriptor.objects.all() assert len(desc) == 1
def test_valid_deletion(self): dummy_user = User.objects.create_user(username="******", password="******") data = desc_utils.DescriptorDataCandidate( desc_utils.DescriptorDataCandidateLocalRawContainer( tools.VALID_SUCC_DESC_C.encode()), user=dummy_user) data.submit() desc = db.Descriptor.objects.all() desc_data_file_path = str(desc[0].data_file) assert tools.file_exists(desc_data_file_path) == True assert len(desc) == 1 client = Client() response = client.login(username="******", password="******") response = client.get("/delete/", { "id": "1", "type": str(DELETE_TYPE_DESCRIPTOR) }) desc = db.Descriptor.objects.all() assert len(desc) == 0 assert tools.file_exists(desc_data_file_path) == False
def test_bad_submissions(self): urldesc_server_obj.add_state( "url1", State(State.SERVER_STATUS_UNREACHABLE, None)) urldesc_server_obj.add_state( "url1", State(State.SERVER_STATUS_VALID, tools.INVALID_DESC_A)) # Getting false for validate() means that submission will not proceed data_cand = desc_utils.DescriptorDataCandidate( desc_utils.DescriptorDataCandidateURLContainer(self.server_url_1), user=self.dummy_user) assert data_cand.validate() == False data_cand = desc_utils.DescriptorDataCandidate( desc_utils.DescriptorDataCandidateURLContainer(self.server_url_1), user=self.dummy_user) assert data_cand.validate() == False
def test_descriptor_valid_unsucc_C(self): data = desc_utils.DescriptorDataCandidate( desc_utils.DescriptorDataCandidateLocalRawContainer( tools.VALID_UNSUCC_DESC_C.encode()), user=self.dummy_user) data.submit() desc = db.Descriptor.objects.all() assert len(desc) == 1 assert tools.valid_unsucc_desc_C_details.compare(desc[0]) == True
def test_descriptor_valid_succ_multiple_tests(self): data = desc_utils.DescriptorDataCandidate( desc_utils.DescriptorDataCandidateLocalRawContainer( tools.VALID_MULTIPLE_TESTS_DESC.encode()), user=self.dummy_user) data.submit() desc = db.Descriptor.objects.all() assert len(desc) == 1 assert tools.multiple_tests_comparator.compare(desc[0]) == True
def _generate_descriptor(self, descriptor_raw): user = self.db_car.user #user = User.objects.get(pk=self.db_car.user_id) is_public = self.db_car.is_public data = desc_utils.DescriptorDataCandidate(desc_utils.DescriptorDataCandidateLocalRawContainer(descriptor_raw), user=user, carmin_platform=self.db_car, is_public=is_public) data.submit(allow_invalid=True) return data
def update(self, to_schedule=False, automatic_updating=True): if (not self.cached_db_desc): desc_data = desc_utils.DescriptorDataCandidate( desc_utils.DescriptorDataCandidateURLContainer(self.url), user=self.user, automatic_updating=automatic_updating) if (desc_data.validate() == True): desc_data.submit() self.cached_db_desc = desc_data.get_db() else: desc_data = desc_utils.DescriptorEntry(self.cached_db_desc) desc_data.update(scheduled=to_schedule)