def test_disallow_delete_dependent_calculation(self): record = self._save_observations_and_calculation() self.name = 'test1' record = self._save_calculation('test') calculation = Calculation.find_one(self.dataset.dataset_id, 'test') self.assertEqual(calculation.dependent_calculations, ['test1']) calculation = Calculation.find_one(self.dataset.dataset_id, 'test') assert_raises(DependencyError, calculation.delete, self.dataset)
def test_disallow_delete_dependent_calculation(self): self._save_observations_and_calculation() self.name = 'test1' self._save_calculation('test') calculation = Calculation.find_one(self.dataset.dataset_id, 'test') self.assertEqual(calculation.dependent_calculations, ['test1']) calculation = Calculation.find_one(self.dataset.dataset_id, 'test') assert_raises(DependencyError, calculation.delete, self.dataset)
def test_removes_dependent_calculations(self): record = self._save_observations_and_calculation() self.name = 'test1' record = self._save_calculation('test') calculation = Calculation.find_one(self.dataset.dataset_id, 'test') self.assertEqual(calculation.dependent_calculations, ['test1']) calculation = Calculation.find_one(self.dataset.dataset_id, 'test1') calculation.delete(self.dataset) calculation = Calculation.find_one(self.dataset.dataset_id, 'test') self.assertEqual(calculation.dependent_calculations, [])
def test_removes_dependent_calculations(self): self._save_observations_and_calculation() self.name = 'test1' self._save_calculation('test') calculation = Calculation.find_one(self.dataset.dataset_id, 'test') self.assertEqual(calculation.dependent_calculations, ['test1']) calculation = Calculation.find_one(self.dataset.dataset_id, 'test1') calculation.delete(self.dataset) calculation = Calculation.find_one(self.dataset.dataset_id, 'test') self.assertEqual(calculation.dependent_calculations, [])
def action(dataset): calculation = Calculation.find_one(dataset.dataset_id, name, group) if calculation: calculation.delete(dataset) message = 'deleted calculation: \'%s\' for dataset: %s' % ( name, dataset.dataset_id) return {self.SUCCESS: message}
def action(dataset): calculation = Calculation.find_one(dataset.dataset_id, name, group) if calculation: calculation.delete(dataset) return self._success('deleted calculation: \'%s\'' % name, dataset_id)
def action(dataset): calculation = Calculation.find_one(dataset.dataset_id, name, group) if calculation: calculation.delete(dataset) return {self.SUCCESS: 'deleted calculation: \'%s\'' % name, Dataset.ID: dataset.dataset_id}
def action(dataset): calculation = Calculation.find_one(dataset.dataset_id, name, group) if calculation: calculation.delete(dataset) return self._success('deleted calculation: \'%s\'' % name, dataset_id)
def __wait_for_calculation_ready(self, dataset_id, name): while True: calculation = Calculation.find_one(dataset_id, name) if calculation.is_ready: break sleep(self.SLEEP_DELAY)
def test_fail_then_create(self): response = json.loads(self.__post_formula()) self.__verify_create(response) # Overwrite as failed calc = Calculation.find_one(self.dataset_id, self.name) calc.update({calc.STATE: calc.STATE_FAILED}) # Test we can still add a calculation self.name = 'test2' response = json.loads(self.__post_formula()) self.__verify_create(response)
def test_fail_in_background(self): dataset_id = self._post_file('wp_data.csv') group = 'wp_id' self._wait_for_dataset_state(dataset_id) self.controller.create(dataset_id, 'newest(submit_date,functional)', 'wp_functional', group=group) self.controller.create(dataset_id, 'max(submit_date)', 'latest_submit_date', group=group) # Update the name to cause has pending to be true and infinite retries. # It will fail after 10 retries. calc = Calculation.find_one(dataset_id, 'latest_submit_date', group) calc.update({calc.NAME: 'another_name'}) update = { 'wp_id': 'D', 'functional': 'yes', } self.__post_update(dataset_id, update) update = { 'submit_date': '2013-01-08', 'wp_id': 'A', 'functional': 'no', } self.__post_update(dataset_id, update) while True: dataset = Dataset.find_one(dataset_id) calcs_not_pending = [ c.state != c.STATE_PENDING for c in dataset.calculations()] if not len(dataset.pending_updates) and all(calcs_not_pending): break sleep(self.SLEEP_DELAY) for c in dataset.calculations(): self.assertEqual(c.STATE_FAILED, c.state) self.assertTrue('Traceback' in c.error_message)
def test_sets_dependent_calculations(self): self._save_observations_and_calculation() self.name = 'test1' self._save_calculation('test') calculation = Calculation.find_one(self.dataset.dataset_id, 'test') self.assertEqual(calculation.dependent_calculations, ['test1'])