Esempio n. 1
0
    def test_dump_toggles(self):
        dumper = ToggleDumper(self.domain_name, [])
        dumper._user_ids_in_domain = Mock(return_value={'user1', 'user2', 'user3'})

        output_stream = StringIO()

        with mock_out_couch(docs=[doc.to_json() for doc in self.mocked_toggles.values()]):
            dumper.dump(output_stream)
        output_stream.seek(0)
        lines = output_stream.readlines()
        dumped = [json.loads(line.strip()) for line in lines]
        self.assertEqual(len(dumped), 3, ','.join([d['slug'] for d in dumped]))
        for dump in dumped:
            self.assertItemsEqual(self.expected_items[dump['slug']], dump['enabled_users'])
Esempio n. 2
0
    def test_dump_toggles(self):
        mocked_toggles, expected_items = self._get_mocked_toggles()

        dumper = ToggleDumper(self.domain_name, [])
        dumper._user_ids_in_domain = Mock(return_value={'user1', 'user2', 'user3'})

        output_stream = BytesIO()

        with mock_out_couch(docs=[doc.to_json() for doc in mocked_toggles.values()]):
            dump_counter = dumper.dump(output_stream)

        self.assertEqual(3, dump_counter['Toggle'])
        output_stream.seek(0)
        dumped = [json.loads(line.strip()) for line in output_stream.readlines()]
        for dump in dumped:
            self.assertItemsEqual(expected_items[dump['slug']], dump['enabled_users'])
Esempio n. 3
0
    def test_dump_toggles(self):
        mocked_toggles, expected_items = self._get_mocked_toggles()

        dumper = ToggleDumper(self.domain_name, [])
        dumper._user_ids_in_domain = Mock(return_value={'user1', 'user2', 'user3'})

        output_stream = StringIO()

        with mock_out_couch(docs=[doc.to_json() for doc in mocked_toggles.values()]):
            dump_counter = dumper.dump(output_stream)

        self.assertEqual(3, dump_counter['Toggle'])
        output_stream.seek(0)
        dumped = [json.loads(line.strip()) for line in output_stream.readlines()]
        for dump in dumped:
            self.assertItemsEqual(expected_items[dump['slug']], dump['enabled_users'])
Esempio n. 4
0
    def test_dump_toggles(self):
        dumper = ToggleDumper(self.domain_name, [])
        users = {'user1', 'user2', 'user3'}

        output_stream = StringIO()

        with mock_out_couch(docs=[doc.to_json() for doc in self.mocked_toggles.values()]), \
             patch("corehq.apps.dump_reload.couch.dump.get_all_usernames_by_domain", return_value=users):
            dumper.dump(output_stream)
        output_stream.seek(0)
        lines = output_stream.readlines()
        dumped = [json.loads(line.strip()) for line in lines]
        self.assertEqual(len(dumped), 3, ','.join([d['slug'] for d in dumped]))
        for dump in dumped:
            self.assertItemsEqual(self.expected_items[dump['slug']],
                                  dump['enabled_users'])