
from django.test import TestCase

class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.failUnlessEqual(1 + 1, 2)

__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.

>>> 1 + 1 == 2
True
"""}


from datetime import datetime

from django.test import TestCase
from unittest import skip

from .models import Person
from mks.models import Member


class PersonTests(TestCase):

    @skip
    def test_member_person_sync(self):
        """
        Test member/person sync on member save()
        """

        birth = datetime.now()

        defaults = {
            'name': 'The MK',
            'date_of_birth': birth,
            'family_status': 'XYZ',
            'place_of_residence': 'AAA',
            'phone': '000-1234',
            'fax': '999-8765',
            'gender': 'F',
        }
        mk = Member.objects.create(**defaults)

        self.assertGreater(mk.person.count(), 0)

        person = Person.objects.filter(mk=mk)[0]

        for field in defaults:
            self.assertEqual(getattr(mk, field), getattr(person, field))

        mk.delete()

Test case for Member/Person sync
Test case for Member/Person sync

Skipped for now, to help with #4049

+ from datetime import datetime
  
  from django.test import TestCase
+ from unittest import skip
  
+ from .models import Person
+ from mks.models import Member
- class SimpleTest(TestCase):
-     def test_basic_addition(self):
-         """
-         Tests that 1 + 1 always equals 2.
-         """
-         self.failUnlessEqual(1 + 1, 2)
- 
- __test__ = {"doctest": """
- Another way to test that 1 + 1 is equal to 2.
- 
- >>> 1 + 1 == 2
- True
- """}
  
  
+ class PersonTests(TestCase):
+ 
+     @skip
+     def test_member_person_sync(self):
+         """
+         Test member/person sync on member save()
+         """
+ 
+         birth = datetime.now()
+ 
+         defaults = {
+             'name': 'The MK',
+             'date_of_birth': birth,
+             'family_status': 'XYZ',
+             'place_of_residence': 'AAA',
+             'phone': '000-1234',
+             'fax': '999-8765',
+             'gender': 'F',
+         }
+         mk = Member.objects.create(**defaults)
+ 
+         self.assertGreater(mk.person.count(), 0)
+ 
+         person = Person.objects.filter(mk=mk)[0]
+ 
+         for field in defaults:
+             self.assertEqual(getattr(mk, field), getattr(person, field))
+ 
+         mk.delete()
+ 
Test case for Member/Person sync
## Code Before:

from django.test import TestCase

class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.failUnlessEqual(1 + 1, 2)

__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.

>>> 1 + 1 == 2
True
"""}


## Instruction:
Test case for Member/Person sync
## Code After:
from datetime import datetime

from django.test import TestCase
from unittest import skip

from .models import Person
from mks.models import Member


class PersonTests(TestCase):

    @skip
    def test_member_person_sync(self):
        """
        Test member/person sync on member save()
        """

        birth = datetime.now()

        defaults = {
            'name': 'The MK',
            'date_of_birth': birth,
            'family_status': 'XYZ',
            'place_of_residence': 'AAA',
            'phone': '000-1234',
            'fax': '999-8765',
            'gender': 'F',
        }
        mk = Member.objects.create(**defaults)

        self.assertGreater(mk.person.count(), 0)

        person = Person.objects.filter(mk=mk)[0]

        for field in defaults:
            self.assertEqual(getattr(mk, field), getattr(person, field))

        mk.delete()
