# Path: django_cassandra_engine/test.py
# class TestCase(DjangoTestCase):
#     databases = list(get_cassandra_db_aliases())
# 
#     def _should_reload_connections(self):
#         return False
# 
#     def _fixture_teardown(self):
#         """
#         Allow normal django TestCase fixture teardown, but also flush the test
#         database for each cassandra alias.
#         """
#         super(TestCase, self)._fixture_teardown()
# 
#         for alias, _ in get_cassandra_connections():
#             # Flush the database
#             call_command(
#                 "flush",
#                 verbosity=1,
#                 interactive=False,
#                 database=alias,
#                 skip_checks=True,
#                 reset_sequences=False,
#                 allow_cascade=False,
#                 inhibit_post_migrate=True,
#             )


from datetime import datetime
from http import client
from unittest import skipIf
from django.urls import reverse
from rest_framework.test import APITestCase
from common.models import (
    CassandraFamilyMember,
    CassandraThing,
    CassandraThingMultiplePK,
)
from common.serializers import CassandraFamilyMemberSerializer
from django_cassandra_engine.test import TestCase as CassandraTestCase
import uuid


class TestListCreateAPIViewWithMultiplePK(APITestCase):
    def setUp(self):
        self.data = {
            "id": "a9be910b-3338-4340-b773-f7ec2bc1ce1a",
            "another_id": "a9be910b-3338-4340-b773-f7ec2bc1ce1b",
            "data_abstract": "TeXt",
            "created_on": "2016-11-12T23:12",
        }

    def test_create_multiple_pk_thing(self):
        url = reverse("thing_listcreate_api")
        response = self.client.post(url, self.data)
        expected_json = {
            "another_id": "a9be910b-3338-4340-b773-f7ec2bc1ce1b",
            "created_on": "2016-11-12T23:12:00Z",
            "data_abstract": "TeXt",
            "id": "a9be910b-3338-4340-b773-f7ec2bc1ce1a",
        }
        self.assertEqual(response.status_code, client.CREATED)
        self.assertDictEqual(response.json(), expected_json)

        model = CassandraThingMultiplePK.objects.get(id=self.data["id"])

        self.assertEqual(str(model.id), self.data["id"])
        self.assertEqual(str(model.another_id), self.data["another_id"])
        self.assertEqual(model.data_abstract, self.data["data_abstract"])



# Path: django_cassandra_engine/test.py
# class TestCase(DjangoTestCase):
#     databases = list(get_cassandra_db_aliases())
# 
#     def _should_reload_connections(self):
#         return False
# 
#     def _fixture_teardown(self):
#         """
#         Allow normal django TestCase fixture teardown, but also flush the test
#         database for each cassandra alias.
#         """
#         super(TestCase, self)._fixture_teardown()
# 
#         for alias, _ in get_cassandra_connections():
#             # Flush the database
#             call_command(
#                 "flush",
#                 verbosity=1,
#                 interactive=False,
#                 database=alias,
#                 skip_checks=True,
#                 reset_sequences=False,
#                 allow_cascade=False,
#                 inhibit_post_migrate=True,
#             )


# Path: testproject/common/tests/test_drf.py
from datetime import datetime
from http import client
from unittest import skipIf
from django.urls import reverse
from rest_framework.test import APITestCase
from common.models import (
    CassandraFamilyMember,
    CassandraThing,
    CassandraThingMultiplePK,
)
from common.serializers import CassandraFamilyMemberSerializer
from django_cassandra_engine.test import TestCase as CassandraTestCase
import uuid



class TestListCreateAPIViewWithMultiplePK(APITestCase):
    def setUp(self):
        self.data = {
            "id": "a9be910b-3338-4340-b773-f7ec2bc1ce1a",
            "another_id": "a9be910b-3338-4340-b773-f7ec2bc1ce1b",
            "data_abstract": "TeXt",
            "created_on": "2016-11-12T23:12",
        }

    def test_create_multiple_pk_thing(self):
        url = reverse("thing_listcreate_api")
        response = self.client.post(url, self.data)
        expected_json = {
            "another_id": "a9be910b-3338-4340-b773-f7ec2bc1ce1b",
            "created_on": "2016-11-12T23:12:00Z",
            "data_abstract": "TeXt",
            "id": "a9be910b-3338-4340-b773-f7ec2bc1ce1a",
        }
        self.assertEqual(response.status_code, client.CREATED)
        self.assertDictEqual(response.json(), expected_json)

        model = CassandraThingMultiplePK.objects.get(id=self.data["id"])

        self.assertEqual(str(model.id), self.data["id"])
        self.assertEqual(str(model.another_id), self.data["another_id"])
        self.assertEqual(model.data_abstract, self.data["data_abstract"])



class TestSerializer(APITestCase, CassandraTestCase):