Skip to content

Commit

Permalink
rm test
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall authored Dec 28, 2024
1 parent 111c435 commit 01bd232
Showing 1 changed file with 0 additions and 155 deletions.
155 changes: 0 additions & 155 deletions tests/islandora_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,160 +1531,5 @@ def TestUpdateMediaFields():
def tearDown():
pass


class TestMultipleParents(unittest.TestCase):

def setUp(self):
self.current_dir = os.path.dirname(os.path.abspath(__file__))
self.create_config_file_path = os.path.join(
self.current_dir, "assets", "create_multi_parents", "create.yml"
)

yaml = YAML()
with open(self.create_config_file_path, "r") as f:
config_file_contents = f.read()
config_data = yaml.load(config_file_contents)
config = {}
for k, v in config_data.items():
config[k] = v
self.islandora_host = config["host"]

self.create_cmd = ["./workbench", "--config", self.create_config_file_path]
self.temp_dir = "/tmp"

def test_secondary_task(self):
requests.packages.urllib3.disable_warnings()
self.nids = list()
create_output = subprocess.check_output(self.create_cmd)
create_output = create_output.decode().strip()

create_lines = create_output.splitlines()
for line in create_lines:
if "created at" in line:
nid = line.rsplit("/", 1)[-1]
nid = nid.strip(".")
self.nids.append(nid)

self.assertEqual(len(self.nids), 3)

# create the child CSV based on the parents created
self.children_csv_file_path = os.path.join(
self.current_dir, "assets", "create_multi_parents", "children.csv"
)
headers = ["id", "title", "field_model", "field_member_of"]
data = [
{
"id": "001",
"title": "Child 1, 2",
"field_model": "Image",
"field_member_of": "|".join(map(str, self.nids[:2])),
},
{
"id": "002",
"title": "Child 1",
"field_model": "Image",
"field_member_of": str(self.nids[0]),
},
{
"id": "004",
"title": "Child 1, 2, 3",
"field_model": "Image",
"field_member_of": "|".join(map(str, self.nids[:3])),
},
{
"id": "005",
"title": "No parent",
"field_model": "Image",
"field_member_of": "",
},
]

# Write to CSV
with open(self.children_csv_file_path, mode="w", newline="") as file:
writer = csv.DictWriter(file, fieldnames=headers)
writer.writeheader()
writer.writerows(data)

self.child_config_file_path = os.path.join(
self.current_dir, "assets", "create_multi_parents", "children.yml"
)
child_cmd = ["./workbench", "--config", self.child_config_file_path]
create_output = subprocess.check_output(child_cmd)
create_output = create_output.decode().strip()

self.child_nids = list()
create_output = subprocess.check_output(child_cmd)
create_output = create_output.decode().strip()

create_lines = create_output.splitlines()
for line in create_lines:
if "created at" in line:
nid = line.rsplit("/", 1)[-1]
nid = nid.strip(".")
self.child_nids.append(nid)

self.assertEqual(len(self.child_nids), 4)

for nid in self.child_nids:
node_url = self.islandora_host + "/node/" + nid + "?_format=json"
response = requests.get(node_url, verify=False)
node_json = json.loads(response.text)
if node_json["title"][0]["value"] == "Child 1, 2":
self.assertEqual(len(node_json["field_member_of"]), 2)
elif node_json["title"][0]["value"] == "Child 1":
self.assertEqual(len(node_json["field_member_of"]), 1)
elif node_json["title"][0]["value"] == "Child 1, 2, 3":
self.assertEqual(len(node_json["field_member_of"]), 3)

def tearDown(self):
for nid in self.nids:
quick_delete_cmd = [
"./workbench",
"--config",
self.create_config_file_path,
"--quick_delete_node",
self.islandora_host + "/node/" + nid,
]
subprocess.check_output(quick_delete_cmd)
for nid in self.child_nids:
quick_delete_cmd = [
"./workbench",
"--config",
self.child_config_file_path,
"--quick_delete_node",
self.islandora_host + "/node/" + nid,
]
subprocess.check_output(quick_delete_cmd)
preprocessed_csv_path = os.path.join(
self.current_dir,
"assets",
"create_multi_parents",
"metadata.csv.preprocessed",
)
if os.path.exists(preprocessed_csv_path):
os.remove(preprocessed_csv_path)

secondary_preprocessed_csv_path = os.path.join(
self.temp_dir, "children.csv.preprocessed"
)
if os.path.exists(secondary_preprocessed_csv_path):
os.remove(secondary_preprocessed_csv_path)

if os.path.exists(self.children_csv_file_path):
os.remove(self.children_csv_file_path)

map_file_path = os.path.join(
self.current_dir, "assets", "create_multi_parents", "id_to_node_map.tsv"
)
if os.path.exists(map_file_path):
os.remove(map_file_path)

rollback_file_path = os.path.join(
self.current_dir, "assets", "create_multi_parents", "rollback.csv"
)
if os.path.exists(rollback_file_path):
os.remove(rollback_file_path)


if __name__ == "__main__":
unittest.main()

0 comments on commit 01bd232

Please sign in to comment.