
from __future__ import unicode_literals

from aldryn_faq.menu import FaqCategoryMenu
from django.utils.translation import (
    get_language_from_request,
)
from .test_base import AldrynFaqTest, CMSRequestBasedTest


class TestMenu(AldrynFaqTest, CMSRequestBasedTest):

    def test_get_nodes(self):
        # Test that the EN version of the menu has only category1 and is shown
        # in English.
        request = self.get_page_request(None, self.user, '/en/')
        menu = FaqCategoryMenu()
        category1 = self.reload(self.category1, 'en')
        self.assertEqualItems(
            [menuitem.title for menuitem in menu.get_nodes(request)],
            [category1.name]
        )

        # Test that the DE version has 2 categories and that they are shown in
        # German.
        request = self.get_page_request(None, self.user, '/de/')
        menu = FaqCategoryMenu()
        category1 = self.reload(self.category1, 'de')
        category2 = self.reload(self.category2, 'de')
        nodes = menu.get_nodes(request)
        self.assertEqualItems(
            [menuitem.title for menuitem in nodes],
            [category1.name, category2.name]
        )


from __future__ import unicode_literals

from aldryn_faq.menu import FaqCategoryMenu

from .test_base import AldrynFaqTest, CMSRequestBasedTest


class TestMenu(AldrynFaqTest, CMSRequestBasedTest):

    def test_get_nodes(self):
        # Test that the EN version of the menu has only category1 and its
        # question1, and is shown in English.
        request = self.get_page_request(None, self.user, '/en/')
        menu = FaqCategoryMenu()
        category1 = self.reload(self.category1, 'en')
        question1 = self.reload(self.question1, 'en')
        self.assertEqualItems(
            [menuitem.title for menuitem in menu.get_nodes(request)],
            [category1.name, question1.title]
        )

        # Test that the DE version has 2 categories and their questions that
        # they are shown in German.
        request = self.get_page_request(None, self.user, '/de/')
        menu = FaqCategoryMenu()
        nodes = menu.get_nodes(request)
        self.assertEqualItems(
            [menuitem.title for menuitem in nodes],
            [self.category1.name, self.category2.name, self.question1.title,
                self.question2.title]
        )

Fix tests to now include the questions, which are now in the menu
Fix tests to now include the questions, which are now in the menu

  
  from __future__ import unicode_literals
  
  from aldryn_faq.menu import FaqCategoryMenu
+ 
- from django.utils.translation import (
-     get_language_from_request,
- )
  from .test_base import AldrynFaqTest, CMSRequestBasedTest
  
  
  class TestMenu(AldrynFaqTest, CMSRequestBasedTest):
  
      def test_get_nodes(self):
-         # Test that the EN version of the menu has only category1 and is shown
+         # Test that the EN version of the menu has only category1 and its
-         # in English.
+         # question1, and is shown in English.
          request = self.get_page_request(None, self.user, '/en/')
          menu = FaqCategoryMenu()
          category1 = self.reload(self.category1, 'en')
+         question1 = self.reload(self.question1, 'en')
          self.assertEqualItems(
              [menuitem.title for menuitem in menu.get_nodes(request)],
-             [category1.name]
+             [category1.name, question1.title]
          )
  
-         # Test that the DE version has 2 categories and that they are shown in
+         # Test that the DE version has 2 categories and their questions that
-         # German.
+         # they are shown in German.
          request = self.get_page_request(None, self.user, '/de/')
          menu = FaqCategoryMenu()
-         category1 = self.reload(self.category1, 'de')
-         category2 = self.reload(self.category2, 'de')
          nodes = menu.get_nodes(request)
          self.assertEqualItems(
              [menuitem.title for menuitem in nodes],
-             [category1.name, category2.name]
+             [self.category1.name, self.category2.name, self.question1.title,
+                 self.question2.title]
          )
  
Fix tests to now include the questions, which are now in the menu
## Code Before:

from __future__ import unicode_literals

from aldryn_faq.menu import FaqCategoryMenu
from django.utils.translation import (
    get_language_from_request,
)
from .test_base import AldrynFaqTest, CMSRequestBasedTest


class TestMenu(AldrynFaqTest, CMSRequestBasedTest):

    def test_get_nodes(self):
        # Test that the EN version of the menu has only category1 and is shown
        # in English.
        request = self.get_page_request(None, self.user, '/en/')
        menu = FaqCategoryMenu()
        category1 = self.reload(self.category1, 'en')
        self.assertEqualItems(
            [menuitem.title for menuitem in menu.get_nodes(request)],
            [category1.name]
        )

        # Test that the DE version has 2 categories and that they are shown in
        # German.
        request = self.get_page_request(None, self.user, '/de/')
        menu = FaqCategoryMenu()
        category1 = self.reload(self.category1, 'de')
        category2 = self.reload(self.category2, 'de')
        nodes = menu.get_nodes(request)
        self.assertEqualItems(
            [menuitem.title for menuitem in nodes],
            [category1.name, category2.name]
        )

## Instruction:
Fix tests to now include the questions, which are now in the menu
## Code After:

from __future__ import unicode_literals

from aldryn_faq.menu import FaqCategoryMenu

from .test_base import AldrynFaqTest, CMSRequestBasedTest


class TestMenu(AldrynFaqTest, CMSRequestBasedTest):

    def test_get_nodes(self):
        # Test that the EN version of the menu has only category1 and its
        # question1, and is shown in English.
        request = self.get_page_request(None, self.user, '/en/')
        menu = FaqCategoryMenu()
        category1 = self.reload(self.category1, 'en')
        question1 = self.reload(self.question1, 'en')
        self.assertEqualItems(
            [menuitem.title for menuitem in menu.get_nodes(request)],
            [category1.name, question1.title]
        )

        # Test that the DE version has 2 categories and their questions that
        # they are shown in German.
        request = self.get_page_request(None, self.user, '/de/')
        menu = FaqCategoryMenu()
        nodes = menu.get_nodes(request)
        self.assertEqualItems(
            [menuitem.title for menuitem in nodes],
            [self.category1.name, self.category2.name, self.question1.title,
                self.question2.title]
        )
