def test_empty_first_last_name(self): """If first name is empty string but last is not should return None """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("", "") self.assertEqual(result, None)
def test_return_multiple(self): """Ensure function will return all eligeble results """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("artur", "meller") self.assertEqual(len(result), 3)
def test_empty_first_name(self): """If first and last name is empty string should return None """ create_pts() assert len(models.Patient.objects.all()) == 5 result = utils.return_duplicates("", "Katz") assert result is None
def get_queryset(self): initial = self.parse_url_querystring() if (initial.get('first_name', None) is None or initial.get('last_name', None) is None): return [] possible_duplicates = utils.return_duplicates( initial.get('first_name', None), initial.get('last_name', None)) return possible_duplicates
def test_return_multiple_starts_with(self): """Ensure function will return all eligeble results if first name only matches start of the actual names """ create_pts() assert models.Patient.objects.count() == 5 result = utils.return_duplicates("art", "meller") assert len(result) == 4
def test_start_with_last(self): """If last name given only matches the start of the actual name, no results returned (last names are never abbreviated) """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("benjamin", "ka") self.assertEqual(len(result), 0)
def test_start_with_first_wrong_last(self): """If first name given matches start of the actual name but last name does not no results returned """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("ben", "katzington") self.assertEqual(len(result), 0)
def test_start_with_first(self): """If first name given matches the start of the actual name, shoud return result """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("ben", "katz") self.assertEqual(len(result), 1)
def test_wrong_first_name(self): """If last name matches but first name is completely different no results should be returned """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("artur", "katz") self.assertEqual(len(result), 0)
def test_identical_first_last_name(self): """If first and last name exactly match database entry, it should be returned """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("benjamin", "katz") self.assertEqual(len(result), 1)
def test_first_last_off_by_1(self): """If first name and last name have 1 letter difference from true value (letter added or removed) the database entry should still be returned """ create_pts() self.assertEqual(len(models.Patient.objects.all()), 5) result = utils.return_duplicates("benjamian", "ktz") self.assertEqual(len(result), 1)
def form_valid(self, form): first_name_str = form.cleaned_data['first_name'].capitalize() last_name_str = form.cleaned_data['last_name'].capitalize() matching_patients = utils.return_duplicates(first_name_str, last_name_str) querystr = '%s=%s&%s=%s' % ("first_name", first_name_str, "last_name", last_name_str) if len(matching_patients) > 0: intake_url = "%s?%s" % (reverse("core:preintake-select"), querystr) return HttpResponseRedirect(intake_url) intake_url = "%s?%s" % (reverse("core:intake"), querystr) return HttpResponseRedirect(intake_url)