def test_view_for_chained_charfield(self): request = self.factory.get('') # filterchain response = filterchain(request, 'test_app', 'Tag', 'kind', 'test_app', 'TagResource', 'kind', 'music') expected_value = '[{"display": "reggae", "value": 2}, {"display": "rock-and-roll", "value": 1}]' self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_filterchain_view_for_chained_manytomany(self): request = self.factory.get('') response = filterchain(request, 'test_app', 'Writer', 'publications', 'test_app', 'Book', 'writer', 1) expected_value = '[{"display": "Author 3", "value": 3}]' self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_limit_to_choice_for_chained_manytomany(self): request = self.factory.get('') # filterchain response = filterchain(request, 'test_app', 'Writer', 'publications', 'test_app', 'Book1', 'writer', 1) expected_value = '[]' self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_limit_to_choice_for_chained_manytomany(self): request = self.factory.get('') # filterchain response = filterchain(request, 'test_app', 'Writer', 'publications', 'test_app', 'Book1', 'writer', 1) expected_value = '[]' self.assertEquals(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_filterchain_view_for_chained_foreignkey(self): request = self.factory.get('') response = filterchain(request, 'test_app', 'Country', 'continent', 'test_app', 'Location', 'country', 1) expected_value = '[{"value": 1, "display": "Czech republic"}, {"value": 3, "display": "Germany"}, {"value": 4, "display": "Great Britain"}]' self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_limit_to_choice_for_chained_foreignkey(self): request = self.factory.get("") # filterchain response = filterchain( request, "test_app", "Country", "continent", "test_app", "Location1", "country", 1, ) expected_value = '[{"value": 3, "display": "Germany"}, {"value": 4, "display": "Great Britain"}]' self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value) # filterchain_all response = filterchain_all( request, "test_app", "Country", "continent", "test_app", "Location1", "country", 1, ) expected_value = '[{"value": 3, "display": "Germany"}, {"value": 4, "display": "Great Britain"}, {"display": "---------", "value": ""}]' self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_view_for_chained_charfield(self): request = self.factory.get('') # filterchain response = filterchain(request, 'test_app', 'Tag', 'kind', 'test_app', 'TagResource', 'kind', 'music') expected_value = '[{"display": "reggae", "value": 2}, {"display": "rock-and-roll", "value": 1}]' self.assertEquals(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_limit_to_choice_for_chained_foreignkey(self): request = self.factory.get('') # filterchain response = filterchain(request, 'test_app', 'Country', 'continent', 'test_app', 'Location1', 'country', 1) expected_value = '[{"value": 3, "display": "Germany"}, {"value": 4, "display": "Great Britain"}]' self.assertEquals(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value) # filterchain_all response = filterchain_all(request, 'test_app', 'Country', 'continent', 'test_app', 'Location1', 'country', 1) expected_value = '[{"value": 3, "display": "Germany"}, {"value": 4, "display": "Great Britain"}, {"display": "---------", "value": ""}]' self.assertEquals(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_filterchain_view_for_chained_manytomany(self): request = self.factory.get("") response = filterchain( request, "test_app", "Writer", "publications", "test_app", "Book", "writer", 1, ) expected_value = '[{"display": "Author 3", "value": 3}]' self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_limit_to_choice_for_chained_manytomany(self): request = self.factory.get("") # filterchain response = filterchain( request, "test_app", "Writer", "publications", "test_app", "Book1", "writer", 1, ) expected_value = "[]" self.assertEqual(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_filterchain_view_for_chained_foreignkey(self): request = self.factory.get('') response = filterchain(request, 'test_app', 'Country', 'continent', 'test_app', 'Location', 'country', 1) expected_value = '[{"value": 1, "display": "Czech republic"}, {"value": 3, "display": "Germany"}, {"value": 4, "display": "Great Britain"}]' self.assertEquals(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)
def test_filterchain_view_for_chained_manytomany(self): request = self.factory.get('') response = filterchain(request, 'test_app', 'Writer', 'publications', 'test_app', 'Book', 'writer', 1) expected_value = '[{"display": "Author 3", "value": 3}]' self.assertEquals(response.status_code, 200) self.assertJSONEqual(response.content.decode(), expected_value)