def test_get(self, response_json_mock, session_mock): response = requests.Response() response.status_code = 200 session_mock.return_value = response response_json_mock.return_value = {'name': 'Test', 'id': 1} queryset = RestQuerySet(model=RestTestQueryModel) queryset.identifier = 1 single_instance = queryset._get_data() self.assertIsInstance(single_instance[0], RestTestQueryModel)
def test_list(self, response_json_mock, session_mock): response = requests.Response() response.status_code = 200 session_mock.return_value = response response_json_mock.return_value = [{ 'name': 'Test', 'id': 1 }, { 'name': 'Test', 'id': 2 }] queryset = RestQuerySet(model=RestTestQueryModel) multiple_instances = queryset._get_data() self.assertIsInstance(multiple_instances[0], RestTestQueryModel) self.assertIsInstance(multiple_instances[1], RestTestQueryModel) self.assertEqual(multiple_instances[0].id, 1) self.assertEqual(multiple_instances[1].id, 2)