{"action":"created","issue":{"url":"https://api.github.com/repos/bernardopires/django-tenant-schemas/issues/251","labels_url":"https://api.github.com/repos/bernardopires/django-tenant-schemas/issues/251/labels{/name}","comments_url":"https://api.github.com/repos/bernardopires/django-tenant-schemas/issues/251/comments","events_url":"https://api.github.com/repos/bernardopires/django-tenant-schemas/issues/251/events","html_url":"https://github.com/bernardopires/django-tenant-schemas/pull/251","id":65785430,"number":251,"title":"Adapt DTS to be used togheter with Django Rest Framework: APITenantTestCase","user":{"login":"robert-malai","id":3693362,"avatar_url":"https://avatars.githubusercontent.com/u/3693362?v=3","gravatar_id":"","url":"https://api.github.com/users/robert-malai","html_url":"https://github.com/robert-malai","followers_url":"https://api.github.com/users/robert-malai/followers","following_url":"https://api.github.com/users/robert-malai/following{/other_user}","gists_url":"https://api.github.com/users/robert-malai/gists{/gist_id}","starred_url":"https://api.github.com/users/robert-malai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robert-malai/subscriptions","organizations_url":"https://api.github.com/users/robert-malai/orgs","repos_url":"https://api.github.com/users/robert-malai/repos","events_url":"https://api.github.com/users/robert-malai/events{/privacy}","received_events_url":"https://api.github.com/users/robert-malai/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-01T21:44:47Z","updated_at":"2015-08-02T15:57:55Z","closed_at":"2015-08-02T09:32:53Z","pull_request":{"url":"https://api.github.com/repos/bernardopires/django-tenant-schemas/pulls/251","html_url":"https://github.com/bernardopires/django-tenant-schemas/pull/251","diff_url":"https://github.com/bernardopires/django-tenant-schemas/pull/251.diff","patch_url":"https://github.com/bernardopires/django-tenant-schemas/pull/251.patch"},"body":"When using Tom Christie's Django Rest Framework (DRF) together with Django Tenant Schemas (DTS), there are no straightforward methods to adapt DRF test cases to be used with DTS.\r\n\r\nThe solution lies in the adaptations performed by DTS to the Django Unit Test classes; same adaptations must be applied to Django Rest Framework Unit Test classes.\r\n\r\nIn order to keep the core of DTS adaptations in one place only, I propose to create 2 mixins: one for the Request Factory and the other one for Test Case. By combining the existing classes with the aformentioned mixins, we can provide new specialized classes for DRF usage while maintaining backward compatibility for the existing DTS test cases.\r\n\r\nI've tested my modifications within one of my DRF applications and I can validate them."},"comment":{"url":"https://api.github.com/repos/bernardopires/django-tenant-schemas/issues/comments/127039540","html_url":"https://github.com/bernardopires/django-tenant-schemas/pull/251#issuecomment-127039540","issue_url":"https://api.github.com/repos/bernardopires/django-tenant-schemas/issues/251","id":127039540,"user":{"login":"robert-malai","id":3693362,"avatar_url":"https://avatars.githubusercontent.com/u/3693362?v=3","gravatar_id":"","url":"https://api.github.com/users/robert-malai","html_url":"https://github.com/robert-malai","followers_url":"https://api.github.com/users/robert-malai/followers","following_url":"https://api.github.com/users/robert-malai/following{/other_user}","gists_url":"https://api.github.com/users/robert-malai/gists{/gist_id}","starred_url":"https://api.github.com/users/robert-malai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robert-malai/subscriptions","organizations_url":"https://api.github.com/users/robert-malai/orgs","repos_url":"https://api.github.com/users/robert-malai/repos","events_url":"https://api.github.com/users/robert-malai/events{/privacy}","received_events_url":"https://api.github.com/users/robert-malai/received_events","type":"User","site_admin":false},"created_at":"2015-08-02T15:57:55Z","updated_at":"2015-08-02T15:57:55Z","body":"I've introduced the mixin so that the adaptions made for the DTS could be applied for the DRF testcases as well (and we don't repeat our code). In essence, DRF works with DTS without a problem, except the fact that the testcases don't work anymore. \r\n\r\nDTS and DRF both subclass the TestCase basic implementation provided by Django by default. Because I cannot alter the DRF to subclass the DTS testcases for his own APITestCase, I had to create a mixin which I've applied on top of the APITestCase.\r\n\r\nThe problem which I'm trying to solve is at the testcases level: DTS sublasses TestCase and perform some adaptions, DRF subclasses TestCase and NEEDS the adaptions of DTS. I've imagined a mixin wich can be applied in both use cases and solve the problem in a pythonic way.\r\n\r\nAny suggestions to solve it otherwise ?"}}