示例#1
0
    def test_liberate_fetch_info_user_has_groups(self):
        group = Group.objects.create(name="hello")
        self.user.groups.add(group)

        tasks.liberate_fetch_info(None, {
            "user": self.user.id,
            "path": self.mail_dir
        })
        profile_data = json.load(
            open(os.path.join(self.mail_dir, "profile.json")))
        inbox_data = json.load(open(os.path.join(self.mail_dir, "inbox.json")))

        self.assertEqual(inbox_data, {})
        self.assertEqual(
            profile_data, {
                "id": self.user.id,
                "username": self.user.username,
                "is_active": self.user.is_active,
                "join_date": self.user.date_joined.isoformat(),
                "groups": ["hello"],
                "errors": [],
                "preferences": {
                    "prefer_html_email": True,
                    "prefered_domain": None,
                    "display_images": 0,
                }
            })
示例#2
0
    def test_liberate_fetch_info_user_has_prefered_domain(self):
        domain = factories.DomainFactory()
        profile = self.user.inboxenprofile
        profile.prefered_domain = domain
        profile.save()

        tasks.liberate_fetch_info(None, {
            "user": self.user.id,
            "path": self.mail_dir
        })
        profile_data = json.load(
            open(os.path.join(self.mail_dir, "profile.json")))
        inbox_data = json.load(open(os.path.join(self.mail_dir, "inbox.json")))

        self.assertEqual(inbox_data, {})
        self.assertEqual(
            profile_data, {
                "id": self.user.id,
                "username": self.user.username,
                "is_active": self.user.is_active,
                "join_date": self.user.date_joined.isoformat(),
                "groups": [],
                "errors": [],
                "preferences": {
                    "prefer_html_email": True,
                    "prefered_domain": str(domain),
                    "display_images": 0,
                }
            })
示例#3
0
文件: tests.py 项目: Inboxen/Inboxen
    def test_liberate_fetch_info_no_result(self):
        tasks.liberate_fetch_info(None, {"user": self.user.id, "path": self.mail_dir})
        profile_data = json.load(open(os.path.join(self.mail_dir, "profile.json")))
        inbox_data = json.load(open(os.path.join(self.mail_dir, "inbox.json")))

        self.assertEqual(inbox_data, {})
        self.assertEqual(profile_data, {
            "id": self.user.id,
            "username": self.user.username,
            "is_active": self.user.is_active,
            "join_date": self.user.date_joined.isoformat(),
            "groups": [],
            "errors": [],
            "preferences": {
                "prefer_html_email": True,
                "prefered_domain": None,
                "display_images": 0,
            }
        })
示例#4
0
    def test_liberate_fetch_info_results_and_inboxes(self):
        inboxes = factories.InboxFactory.create_batch(2, user=self.user)
        results = [None for i in range(6)]

        tasks.liberate_fetch_info(results, {
            "user": self.user.id,
            "path": self.mail_dir
        })
        profile_data = json.load(
            open(os.path.join(self.mail_dir, "profile.json")))
        inbox_data = json.load(open(os.path.join(self.mail_dir, "inbox.json")))

        self.assertEqual(
            inbox_data, {
                str(box): {
                    "created": box.created.isoformat(),
                    "description": None,
                    "flags": {
                        "deleted": box.deleted,
                        "new": box.new,
                        "exclude_from_unified": box.exclude_from_unified,
                        "disabled": box.disabled,
                        "pinned": box.pinned,
                    },
                }
                for box in inboxes
            })

        self.assertEqual(
            profile_data, {
                "id": self.user.id,
                "username": self.user.username,
                "is_active": self.user.is_active,
                "join_date": self.user.date_joined.isoformat(),
                "groups": [],
                "errors": [],
                "preferences": {
                    "prefer_html_email": True,
                    "prefered_domain": None,
                    "display_images": 0,
                }
            })
示例#5
0
文件: tests.py 项目: Inboxen/Inboxen
    def test_liberate_fetch_info_user_has_prefered_domain(self):
        domain = factories.DomainFactory()
        profile = self.user.inboxenprofile
        profile.prefered_domain = domain
        profile.save()

        tasks.liberate_fetch_info(None, {"user": self.user.id, "path": self.mail_dir})
        profile_data = json.load(open(os.path.join(self.mail_dir, "profile.json")))
        inbox_data = json.load(open(os.path.join(self.mail_dir, "inbox.json")))

        self.assertEqual(inbox_data, {})
        self.assertEqual(profile_data, {
            "id": self.user.id,
            "username": self.user.username,
            "is_active": self.user.is_active,
            "join_date": self.user.date_joined.isoformat(),
            "groups": [],
            "errors": [],
            "preferences": {
                "prefer_html_email": True,
                "prefered_domain": str(domain),
                "display_images": 0,
            }
        })
示例#6
0
文件: tests.py 项目: Inboxen/Inboxen
    def test_liberate_fetch_info_results_and_inboxes(self):
        inboxes = factories.InboxFactory.create_batch(2, user=self.user)
        results = [None for i in range(6)]

        tasks.liberate_fetch_info(results, {"user": self.user.id, "path": self.mail_dir})
        profile_data = json.load(open(os.path.join(self.mail_dir, "profile.json")))
        inbox_data = json.load(open(os.path.join(self.mail_dir, "inbox.json")))

        self.assertEqual(inbox_data, {
            str(box): {
                "created": box.created.isoformat(),
                "description": None,
                "flags": {
                    "deleted": box.deleted,
                    "new": box.new,
                    "exclude_from_unified": box.exclude_from_unified,
                    "disabled": box.disabled,
                    "pinned": box.pinned,
                },
            }
            for box in inboxes
        })

        self.assertEqual(profile_data, {
            "id": self.user.id,
            "username": self.user.username,
            "is_active": self.user.is_active,
            "join_date": self.user.date_joined.isoformat(),
            "groups": [],
            "errors": [],
            "preferences": {
                "prefer_html_email": True,
                "prefered_domain": None,
                "display_images": 0,
            }
        })
示例#7
0
 def test_liberate_fetch_info(self):
     tasks.liberate_fetch_info(None, {
         "user": self.user.id,
         "path": self.mail_dir
     })