Skip to content

Commit

Permalink
More progress on test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Sep 12, 2023
1 parent 188d195 commit 967ac16
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions arches_for_science/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.management import call_command

from django.contrib.auth.models import User
from django.test import TestCase
from django.test.client import Client
from django.urls import reverse
Expand All @@ -19,12 +20,14 @@
def setUpModule():
if not GraphModel.objects.filter(pk=PHYSICAL_THING_GRAPH_ID).exists():
call_command("packages", "-o load_package -s arches_for_science/pkg -y".split())
if not User.objects.filter(username="tester1").exists():
call_command("add_test_users")


class AnalysisAreaAndSampleTakingTests(TestCase):
def login(self):
def login(self, username="dev", password="dev"):
client = Client()
client.login(username="ben", password="Test12345!")
client.login(username=username, password=password)
return client

def get_resource_instance(self, graph_id):
Expand All @@ -46,7 +49,8 @@ def make_tile(self, parent_phys_thing, data, transaction_id):
return new_tile

def test_create_delete_analysis_area(self):
client = self.login()
# TODO: fails with dev/dev? 🤔
client = self.login(username="ben", password="Test12345!")

transaction_id = "10000000-1000-1000-1000-100000000000"
parent_phys_thing = self.get_resource_instance(PHYSICAL_THING_GRAPH_ID)
Expand Down Expand Up @@ -110,23 +114,17 @@ def test_create_delete_sample(self):
part_identifier_assignment_label_nodeid: {
get_language(): {"value": "test value"}
},
physical_part_of_object_nodeid: [
{
"resourceId": str(part.pk),
},
],
part_identifier_assignment_polygon_identifier_nodeid: [],
physical_part_of_object_nodeid: {},
part_identifier_assignment_polygon_identifier_nodeid: {},
statement_type_nodeid: {
get_language(): {"value": "test statement"}
get_language(): {"value": "test statement", "direction": "ltr"}
},
},
),
"sampleMotivation": "Test Motivation",
"sampleDescription": "Test Description",
"samplingActivityResourceId": str(sampling_activity.pk),
}
settings.BYPASS_REQUIRED_VALUE_TILE_VALIDATION = True
self.addCleanup(setattr, settings, "BYPASS_REQUIRED_VALUE_TILE_VALIDATION", False)
response = client.post(reverse("savesamplearea"), create_data)
self.assertEqual(response.status_code, 200)

Expand Down

0 comments on commit 967ac16

Please sign in to comment.