def test_list_pallets_from_config(self): config.set_config_prop('warehouse', test_pallets_folder, override=True) pallets = cli.list_pallets() self.assertEqual(len(pallets), 4) self.assertEqual(pallets[0][0], join(test_pallets_folder, 'multiple_pallets.py')) self.assertEqual(pallets[0][1].__name__, 'PalletOne')
def test_start_lift_with_out_path(self, process_pallets, process_crates_for): config.set_config_prop('warehouse', test_pallets_folder, override=True) cli.start_lift() self.assertEqual(len(process_crates_for.call_args[0][0]), 4) self.assertEqual(len(process_pallets.call_args[0][0]), 4)
def test_list_pallets_from_config(self): config.set_config_prop('warehouse', test_pallets_folder, override=True) pallets, _ = engine.list_pallets() self.assertEqual(len(pallets), 4) self.assertEqual(pallets[0][0], join(test_pallets_folder, 'multiple_pallets.py')) self.assertEqual(pallets[0][1].__name__, 'PalletOne')
def test_lift_pallets_with_out_path(self, process_pallets, process_crates_for, git_update): config.set_config_prop('warehouse', test_pallets_folder, override=True) engine.lift_pallets() self.assertEqual(len(process_crates_for.call_args[0][0]), 4) self.assertEqual(len(process_pallets.call_args[0][0]), 4)
def test_start_lift_update_static(self, update_static_for, process_pallets, process_crates_for, git_update): cli.start_lift(join(test_data_folder, 'pallet_argument.py'), 'test') update_static_for.assert_not_called() config.set_config_prop('copyDestinations', ['a']) cli.start_lift(join(test_data_folder, 'pallet_argument.py'), 'test') update_static_for.assert_called_once()
def test_list_repos(self): config.set_config_prop('repositories', ['blah', 'blah2'], override=True) result = cli.list_repos() self.assertEqual(result, [ 'blah: [Invalid repo name or owner]', 'blah2: [Invalid repo name or owner]' ])
def test_deletes_folders(self): test_staging = join(test_data_folder, 'staging') test_folder = join(test_staging, 'test') mkdir(test_folder) config.set_config_prop('stagingDestination', test_staging) cli.scorched_earth() self.assertFalse(exists(core.scratch_gdb_path)) self.assertFalse(exists(test_folder)) self.assertTrue(exists(test_staging))
def test_deletes_folders(self): test_hash_location = join(test_data_folder, 'hashLocation') test_folder = join(test_hash_location, 'test') if exists(test_folder): rmdir(test_folder) makedirs(test_folder) config.set_config_prop('hashLocation', test_hash_location) engine.scorched_earth() self.assertFalse(exists(core.scratch_gdb_path)) self.assertFalse(exists(test_folder))
def test_set_config_prop_appends_items_from_list_if_not_overriding( self, mock_obj): mock_obj.return_value = {'test': []} message = config.set_config_prop('test', [1, 2, 3]) self.assertEqual(message, 'Added [1, 2, 3] to test')
def test_git_update(self, _validate_repo_mock, _get_repo_mock, clone_from_mock): remote_mock = Mock() remote_mock.pull = Mock() remote_mock.pull.return_value = [] repo_mock = Mock() repo_mock.remotes = [remote_mock] _get_repo_mock.return_value = repo_mock _validate_repo_mock.return_value = '' cli.init() config.set_config_prop('warehouse', test_pallets_folder, override=True) config.set_config_prop('repositories', ['agrc/nested', 'agrc/forklift']) cli.git_update() clone_from_mock.assert_called_once() remote_mock.pull.assert_called_once()
def test_git_update(self, _validate_repo_mock, _get_repo_mock, clone_from_mock): remote_mock = Mock() remote_mock.pull = Mock() remote_mock.pull.return_value = [] repo_mock = Mock() repo_mock.remotes = [remote_mock] _get_repo_mock.return_value = repo_mock _validate_repo_mock.return_value = '' engine.init() config.set_config_prop('warehouse', test_pallets_folder, override=True) config.set_config_prop('repositories', ['agrc/nested', 'agrc/forklift']) results = engine.git_update() clone_from_mock.assert_called_once() remote_mock.pull.assert_called_once() self.assertEqual(len(results), 0)
def test_set_config_prop_overrides_all_values(self): folder = 'blah' config.set_config_prop('warehouse', folder, override=True) self.assertEqual(config.get_config_prop('warehouse'), folder)
def test_copy(self): config.set_config_prop('copyDestinations', ['one', 'two']) report = cli.update_static( join(test_pallets_folder, 'single_pallet.py')) self.assertRegexpMatches(report, 'ran successfully')
def test_no_copy_destinations(self): config.set_config_prop('copyDestinations', []) report = cli.update_static( join(test_pallets_folder, 'single_pallet.py')) self.assertEquals(report, '')
def test_set_config_prop_appends_items_from_list_if_not_overriding(self, mock_obj): mock_obj.return_value = {'test': []} message = config.set_config_prop('test', [1, 2, 3]) self.assertEqual(message, 'Added [1, 2, 3] to test')
def test_set_config_prop_sets_value(self, mock_obj): mock_obj.return_value = {'test': ''} message = config.set_config_prop('test', 'value') self.assertEqual(message, 'Added value to test')
def test_set_config_prop_returns_message_if_not_found(self, mock_obj): mock_obj.return_value = {} message = config.set_config_prop('this was', 'not found') self.assertEqual(message, 'this was not found in config.')
def test_list_repos(self): config.set_config_prop('repositories', ['blah', 'blah2'], override=True) result = cli.list_repos() self.assertEqual(result, ['blah: [Invalid repo name or owner]', 'blah2: [Invalid repo name or owner]'])